PageRenderTime 86ms CodeModel.GetById 40ms app.highlight 12ms RepoModel.GetById 28ms app.codeStats 0ms

/examples/videx/vone.py

http://echo-nest-remix.googlecode.com/
Python | 44 lines | 33 code | 3 blank | 8 comment | 0 complexity | 6811475bcf30d028fe168511c65e43c6 MD5 | raw file
 1#!/usr/bin/env python
 2# encoding: utf-8
 3"""
 4vone.py
 5
 6Created by Ben Lacker on 2009-06-19.
 7Copyright (c) 2009 __MyCompanyName__. All rights reserved.
 8"""
 9
10import sys
11import os
12
13from echonest import audio, video
14
15usage = """
16Usage: 
17    python vone.py <input_filename> <output_filename>
18
19Example:
20    python vone.py EverythingIsOnTheOne.mpg EverythingIsReallyOnTheOne.mpg
21"""
22
23
24def main(input_filename, output_filename):
25    if input_filename.startswith("http://"):
26        av = video.loadavfromyoutube(input_filename)
27    else:
28        av = video.loadav(input_filename)
29    collect = audio.AudioQuantumList()
30    for bar in av.audio.analysis.bars:
31        collect.append(bar.children()[0])
32    out = video.getpieces(av, collect)
33    out.save(output_filename)
34
35
36if __name__ == '__main__':
37    import sys
38    try:
39        input_filename = sys.argv[1]
40        output_filename = sys.argv[2]
41    except:
42        print usage
43        sys.exit(-1)
44    main(input_filename, output_filename)