Skip to content

Instantly share code, notes, and snippets.

@pauladam
Created September 22, 2012 20:14
Show Gist options
  • Select an option

  • Save pauladam/3767668 to your computer and use it in GitHub Desktop.

Select an option

Save pauladam/3767668 to your computer and use it in GitHub Desktop.
movie -> gif89a
#!/usr/bin/ruby
# gif-it
if ARGV.length < 3
puts "usage: gif-it <filename> <start-time> <duration>"
end
fn = ARGV.shift
start_time = ARGV.shift
duration = ARGV.shift
basename = File.basename(fn)
outputfn = "%s.gif" % basename
cmd = "ffmpeg -i \"%s\" -pix_fmt rgb24 -s cif -loop_output 0 -ss %s -t %s -r 6 -y \"%s\""
args = [fn, start_time, duration, basename]
cmd_w_args = cmd % args
puts cmd_w_args
`#{cmd_w_args}`
convert_cmd = "convert -depth 8 %s %s" % [outputfn, outputfn]
puts convert_cmd
`#{convert_cmd}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment