I’ve been attempting to figure this out for forever now (I’m new to programming) and I can’t figure it out.
I’m attempting to build a script that will test the file, and give me output from which I can get information like “Audio Format” that I can then put into the filename. However, I can’t even get the script to return any file info. I’ve hit a wall at inserting an input file…
So at this point I just need help getting it to spit out info based on the argvs I’ve thrown in. Hopefully I’ll be able to figure out how to parse the audio info from that.
My attempt that seems to be close:
#!/usr/bin/python
import os, sys, subprocess, shlex, re
from subprocess import call
def probe_file(filename):
p = subprocess.Popen(['/opt/local/bin/ffprobe', '-show_format', '-pretty', '-loglevel quiet', -i filename], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
print filename
print p.communicate()
[probe_file (f) for f in os.listdir('.') if not f.startswith('.')]
There are a few problems in your code:
-i filenamewhich is a syntax error use'-i '+filenameinsteadshell=Trueis usually not needed and is unnecessary burden.Other than that it seems to be working, are you not seeing output after fixing #1 ?
Edit: Looks like you are having problem with ffprobe commandline, so I installed it and changes you require are:
-iflag, input file is just passed as last argument.-logleveland option of loglevelquietas separate arguments i.e.[..., '-loglevel', 'quiet',..]So after these changes here is a sample script:
And I see the correct output: