Skip to content

Instantly share code, notes, and snippets.

@ucnv
Created September 12, 2009 15:54
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/185886 to your computer and use it in GitHub Desktop.
Save ucnv/185886 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Screen size glitch for xvid encoded avi
require 'aviglitch'
avi = AviGlitch.open ARGV.shift
avi.glitch_with_index(:keyframe) do |data, i|
x = data[25..28].unpack('B*').first
w = rand(('0b' + x[0..12]).oct * 1.5)
h = rand(('0b' + x[14..26]).oct * 1.5)
x[0..12] = "%013b" % ((w > 50) ? w : 50)
x[14..26] = "%013b" % ((h > 50) ? h : 50)
(i == 0) ? data : data[0..24] + [x].pack('B*') + data[29..data.size]
end
avi.output 'out.avi'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment