#!/usr/bin/env ruby # Generate datamoshing require 'optparse' require 'rubygems' require 'aviglitch' output = './out.avi' all = false opts = OptionParser.new do |opts| opts.banner = "datamosh - AviGlitch's datamoshing video generator." opts.define_head "Usage: #{File.basename($0)} [options]" opts.separator "Options:" opts.on("-o", "--output [OUTPUT]", "Output the video to OUTPUT (./out.avi by default)") do |f| output = f end opts.on("-a", "--all", "Remove all keyframes (It remains a first keyframe by default)") do all = true end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end input = opts.parse! if input.empty? puts opts exit 1 end a = AviGlitch.open input.shift a.glitch_with_index :keyframe do |frame, i| (!all && i == 0) ? frame : "\000" * frame.size # keep the first frame end input.each do |file| b = AviGlitch.open file b.glitch :keyframe do |frame| "\000" * frame.size end a.frames.concat b.frames end a.output output