Skip to content

Instantly share code, notes, and snippets.

@amirrajan
Last active November 27, 2017 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amirrajan/80a5adc8bcc50b23e6c8d0aaa7db6e5b to your computer and use it in GitHub Desktop.
Save amirrajan/80a5adc8bcc50b23e6c8d0aaa7db6e5b to your computer and use it in GitHub Desktop.
#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