Skip to content

Instantly share code, notes, and snippets.

@ucnv
Created July 16, 2009 09:54
Show Gist options
  • Select an option

  • Save ucnv/148330 to your computer and use it in GitHub Desktop.

Select an option

Save ucnv/148330 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Usage: ruby datamoshing.rb input.avi > output.avi
input = ARGV.shift
data = File.open(input) {|f| f.read }
header, main = data.split('movi')
frames, indices = main.split('idx1').map do |x|
x.split(/(00dc)/)
end
indices.each_with_index do |d, i|
next if i < 10 # keep keyframes around beginning
if d[0] == 0x10
frames[i] = frames[i].split(/(01wb)/)[1..-1].join
frames[i - 1] = nil
end
end
frames.compact!
print header + 'movi' + frames.join + 'idx1' + indices.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment