Sha256: 8968e57bf84a7cd3783b1e3ef02c24503a59b2bf6c5c2e214aa44a3ee84821c5

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

#!/usr/bin/env ruby
# Generate datamoshing

require 'optparse'
require 'rubygems'
require 'aviglitch'

output = './out.avi'
all = false
fake = 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("--fake", "Remains all keyframes as full pixel included deltaframe") do
    fake = true
    if all
      warn "The --fake option cannot use with -a/--all option.\n"
      exit
    end
  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
unless fake
  a.glitch_with_index :keyframe do |frame, i|
    (!all && i == 0) ? frame : "" # keep the first frame
  end
end
a.clear_keyframes!(!all && !fake ? 1..a.frames.size : nil)

input.each do |file|
  b = AviGlitch.open file
  unless fake
    b.glitch :keyframe do |frame|
      ""
    end
  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.3 bin/datamosh