I have a couple of video container files which contain audio and video in various codecs. Now I'd like to inspect the container from a Python script to know which codec is used for audio+video. This is on a linux box so I have all the tools available if necessary.
I thought that maybe gstreamer could help me here but I was unable to find an API which could help me here.
Any ideas? I'm also open for any suggestion, doesn't need to be gstreamer as long as it is free software :-) fs
ffprobe -show_format -show_streams -loglevel quiet -print_format json YOUR_FILE
Just invoke this with subprocess.check_output and you'll get a beautiful JSON description of your media file. If you need it to grab the data from stdin, replace YOUR_FILE with pipe:0.
ffprobe comes with ffmpeg.
Try downloading the ffmpeg source and look at the source for their command line programs. I've hacked up similar utilities in the past. I'm not posting my solution because ffmpeg likes to change their API, so my old code is unlikely to compile with the current version. You'll want to do enough work to create codec context, which you can inspect to get what you need.
Some other alternatives:
MediaInfo: http://mediainfo.sourceforge.net/en
GSpot (Windows only): http://www.headbands.com/gspot/
EDIT:
http://code.google.com/p/pyffmpeg/ might have what you want (I haven't used it myself).
You can use decodebin2 in Gstreamer. Take a look at TAE for code examples.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With