Created
March 28, 2009 15:31
-
-
Save koyachi/87120 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
config = Mash.new YAML.load(File.open('config.yaml')) | |
en = WebService::EchoNest.new config[:api_key] | |
response = en.get_beats :id => "music://id.echonest.com/~/TR/TRQTAUB1204D807B19" | |
p response | |
p "\n\n\n" | |
beat8s = [] | |
prev = response[:beats][0] | |
p prev | |
response[:beats].each_with_index do |beat, i| | |
if i % 8 == 0 | |
p beat | |
beat8s.push({ | |
:start => Float(prev[:value]), | |
:duration => Float(beat[:value]) - Float(prev[:value]), | |
}) | |
prev = beat | |
end | |
end | |
first_duration = beat8s[0][:start] | |
beat8s[0] = { | |
:start => 0.0, | |
:duration => first_duration, | |
} | |
beat8s.shuffle! | |
p beat8s | |
video = 'FredvomJupiter.avi' | |
videos = [] | |
beat8s.each_with_index do |beat, i| | |
v = "tmp/beat_#{i}.avi" | |
cmd = "ffmpeg -i #{video} -ss #{beat[:start]} -t #{beat[:duration]} #{v}" | |
p cmd | |
system cmd | |
videos.push v | |
end | |
cmd = "mencoder " + videos.join(' ') + " -o shuffled.avi -oac copy -ovc copy" | |
p cmd | |
system cmd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment