Python: detecting codecs used in a video container

I have several video containers that contain audio and video in various codecs. Now I would like to inspect the container with the Python script to find out which codec is used for audio + video. This is in the linux box, so I have all the tools available if necessary.

I thought maybe gstreamer could help me here, but I could not find an API that could help me here.

Any ideas? I am also open to any suggestion, it does not have to be gstreamer while this is free software :-) fs

+5
source share
3 answers

Try loading the ffmpeg source and look at the source for their command line programs. In the past, I hacked such utilities. I am not posting my solution because ffmpeg likes to change its API, so my old code is unlikely to compile with the current version. You want to do enough work to create a codec context that you can check to get what you need.

Some other options:


EDIT:

http://code.google.com/p/pyffmpeg/ may have what you want (I haven't used it myself).

+3
source
ffprobe -show_format -show_streams -loglevel quiet -print_format json YOUR_FILE

subprocess.check_output, JSON. , stdin, YOUR_FILE : 0.

ffprobe ffmpeg.

+6

You can use decodebin2 in Gstreamer. See TAE for code examples.

+1
source

All Articles