-
-
Save ucnv/972563 to your computer and use it in GitHub Desktop.
makes glitch beats using AviGlitch (2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'aviglitch' | |
unless ARGV.size >= 2 | |
puts "Usage: ruby #{$0} INFILE PATTERN [FPS]" | |
puts " ruby #{$0} file.mp3 0010001000010011" | |
exit | |
end | |
infile, pattern, fps = ARGV | |
fps = 60 unless fps | |
cmd = "ffmpeg -i %s -sameq -r %d -vn tmp1.avi" % [infile, fps] | |
system cmd | |
a = AviGlitch.open 'tmp1.avi' | |
a.glitch_with_index do |f, i| | |
if pattern[i % pattern.size] == '1' | |
a.frames[rand(a.frames.size)].data | |
else | |
f | |
end | |
end | |
a.output 'tmp2.avi' | |
outfile = 'out' + Pathname(infile).extname | |
cmd = "ffmpeg -i tmp2.avi -sameq -y %s" % outfile | |
system cmd | |
Dir.glob('tmp*.avi').each {|f| File.unlink f } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment