简体   繁体   English

python openCV 编解码器信息

[英]python openCV codec info

Let's say there are some mov files.假设有一些 mov 文件。 I want to know what codec each mov is using.我想知道每个 mov 使用的编解码器。 Can anyone help me?谁能帮我? I need to get "h264" as in the image, not Input(AVC1).我需要获得图像中的“h264”,而不是输入(AVC1)。

import cv2
import glob

mov_files = glob.glob('*.mp4')

for eachFile in mov_files:
    cap = cv2.VideoCapture(eachFile)
    file_length = cap.get(cv2.CAP_PROP_FRAME_COUNT)
    print(file_length)
    codec ??
    print(codec)

在此处输入图像描述

在此处输入图像描述

You can find the 4 character code of the video codec using below:您可以使用以下方法找到视频编解码器的 4 字符代码:

h = int(cap.get(cv2.CAP_PROP_FOURCC))
codec = chr(h&0xff) + chr((h>>8)&0xff) + chr((h>>16)&0xff) + chr((h>>24)&0xff)

UPDATE:更新:

With OpenCV only the FourCC information for the video codec is possible to get.使用 OpenCV 只能获取视频编解码器的 FourCC 信息。 No further information on codec is available.没有关于编解码器的更多信息。 You can refer to the link: https://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture可以参考链接: https://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture

And also the list of FourCC codes: http://www.fourcc.org/codecs.php还有 FourCC 代码列表: http://www.fourcc.org/codecs.php

So as per this question, you can get the FourCC code information only by using OpenCV. For further details on the codec you may need to use other libraries.因此,根据这个问题,您只能使用 OpenCV 获取 FourCC 代码信息。有关编解码器的更多详细信息,您可能需要使用其他库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM