-
-
Save amirrajan/80a5adc8bcc50b23e6c8d0aaa7db6e5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#command: | |
#rake create_video -- --source=./preview-video-iphone-x.mov --times=0:30-0:45,0:15-0:65,0:13-4:40 | |
require 'optparse' | |
task :create_video do | |
options = {} | |
o = OptionParser.new do |opts| | |
opts.banner = "Usage: rake add [options]" | |
opts.on("-s SOURCE", "--source SOURCE", String) { |source| options[:source] = source } | |
opts.on("-t TIMES", "--times TIMES", String) { |times| options[:times] = times } | |
end | |
args = o.order!(ARGV) {} | |
o.parse!(args) | |
puts options[:source] | |
puts options[:times] | |
time_values = options[:times].split(',').map do |token| | |
puts token | |
start_t = token.split('-').first | |
puts start_t | |
end_t = token.split('-').last | |
puts end_t | |
{ start_t: start_t, end_t: end_t} | |
end | |
puts "#{time_values}" | |
# create multiple videos | |
time_values.map do |t| | |
#puts "#{t}" | |
#puts "ffmpeg #{t[:start_t]} #{t[:end_t]}" | |
#sh "ffmpeg #{t[:start_t]} #{t[:end_t]}" | |
end | |
# combine plus cross fade | |
# speed up if needed | |
# resize | |
puts "ffmpeg -i #{options[:source]} -vf scale=1920:886 output.mov" | |
sh "ffmpeg -i #{options[:source]} -vf scale=1920:886 output.mov" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment