cmd
in your example is a shell pipeline. subprocess.call()
doesn't call the shell by default i.e., your command should fail unless you specify shell=True
(use string argument in this case). To get output, you could call:
output = subprocess.check_output(cmd, shell=True)
You could avoid calling shell commands and use pure Python parser demonstrated in How to get .avi files length question instead:
#!/usr/bin/env python
from glob import glob
from hachoir_metadata import extractMetadata
from hachoir_parser import createParser
entries = [(path, extractMetadata(createParser(path)).get('duration'))
for path in glob(u"*.wav")]
print "Min: path(%s), duration(%s)" % min(entries, key=lambda (_,d): d)
print "Max: path(%s), duration(%s)" % max(entries, key=lambda (_,d): d)
print "Total: duration(%s seconds)" % sum(d.total_seconds() for _, d in entries)
To install the hachoir library, run:
$ pip install hachoir-{core,parser,metadata}