Let's say there are some mov files. I want to know what codec each mov is using. Can anyone help me? I need to get "h264" as in the image, not Input(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:
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. 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
And also the list of FourCC codes: 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.