bin/datamosh in aviglitch-0.0.2 vs bin/datamosh in aviglitch-0.0.3
- old
+ new
@@ -5,47 +5,44 @@
require 'rubygems'
require 'aviglitch'
output = './out.avi'
all = false
-force = false
opts = OptionParser.new do |opts|
opts.banner = "datamosh - AviGlitch's datamoshing video generator."
opts.define_head "Usage: #{File.basename($0)} <input> [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("-f", "--force", "Overwrite an existing output file") do
- force = true
- 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
-if !force && File.exists?(output)
- puts "!!! `#{output}' already exists. Use -f option to overwrite."
- exit 1
-end
-a = AviGlitch.open input.first
+a = AviGlitch.open input.shift
a.glitch_with_index :keyframe do |frame, i|
- if !all && i == 0 # keep the first frame
- frame
- else
+ (!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)
+
+a.output output