Skip to content

Instantly share code, notes, and snippets.

@ucnv
Created September 19, 2010 00:29
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 ucnv/586209 to your computer and use it in GitHub Desktop.
Save ucnv/586209 to your computer and use it in GitHub Desktop.
require 'aviglitch'
unit = 3
step = 1
cmd = "ffmpeg -i %s -an -vcodec copy -r 30 tmp.avi" % ARGV.shift
system cmd
g = AviGlitch.open "tmp.avi"
g.glitch :keyframe do |x|
nil
end
q = nil
(g.frames.size / step).to_i.times do |i|
pos = i * step
f = g.frames[pos, unit]
if q.nil?
q = f
else
q.concat f
end
printf "\r>> %4d/%d", pos, g.frames.size
$stdout.flush
end
puts
AviGlitch.open(q).output("out.avi")
File.unlink("tmp.avi")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment