How can I identify a video format in Python3?
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?
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
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.
链接地址: http://www.djcxy.com/p/46810.html上一篇: 从django应用程序调用unoconv时出现的问题,在virtualenv中运行
下一篇: 我如何在Python3中识别视频格式?