#!/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] file [file2 ...]" 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 : nil # keep the first frame end input.each do |file| b = AviGlitch.open file b.glitch :keyframe do |frame| nil end a.frames.concat b.frames end a.output output