Domanda

I'd like to be able to open a given file, and see that "This is a MP4 file", or "This is a webm" file, or even "This does not appear to be a valid video"

I saw the FFmpeg wrapper, at https://code.google.com/p/pyffmpeg/, but I didn't see any sort of get_codec function inside of it.

Thoughts?

È stato utile?

Soluzione

Take a look at Hachoir. It 'extracts metadata from multimedia files'.

Here's their example of metadata extraction from an AVI file:

$ hachoir-metadata pacte_des_gnous.avi
Common:
- Duration: 4 min 25 sec
- Comment: Has audio/video index (248.9 KB)
- MIME type: video/x-msvideo
- Endian: Little endian
Video stream:
- Image width: 600
- Image height: 480
- Bits/pixel: 24
- Compression: DivX v4 (fourcc:"divx")
- Frame rate: 30.0
Audio stream:
- Channel: stereo
- Sample rate: 22.1 KHz
- Compression: MPEG Layer 3

Altri suggerimenti

My python is a bit rusty, but a quick look over the module turns these up.

To get the Codec ID:

Track.CodecCtx.codec_id

To get the Codec itself (AVCodec):

Track.Codec

AVCodec contains the codec name.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top