Sha256: 01a11a92f6752eb8e9492c29a5933e0d5e6be37b85a3f07048a827229a2a6135

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

#!/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 = Dir.glob 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 : "" # keep the first frame
end
a.clear_keyframes!(!all ? 1..a.frames.size : nil)

input.each do |file|
  b = AviGlitch.open file
  b.glitch :keyframe do |frame|
    ""
  end
  b.clear_keyframes!
  a.frames.concat b.frames
end

a.output output

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aviglitch-0.1.2 bin/datamosh