opencv CV2 读取视频信息

import cv2

video_path = "     "
video_capture = cv2.VideoCapture(video_path)
video_FourCC = int(video_capture.get(cv2.CAP_PROP_FOURCC))
video_width = int(video_capture.get(3))
video_height = int(video_capture.get(4))
video_size = (int(video_capture.get(cv2.CAP_PROP_FRAME_WIDTH)),
              int(video_capture.get(cv2.CAP_PROP_FRAME_HEIGHT)))
print("video size:{}".format(video_size))  # (1920, 1080)
# 视频总帧数
total_frames = int(video_capture.get(cv2.CAP_PROP_FRAME_COUNT))  # 14861
print("total_frame:{}".format(total_frames))

# 视频帧率
video_fps = int(video_capture.get(5))
print("video_fps:{}".format(video_fps))
# video_fps_1 = video_capture.get(cv2.CAP_PROP_FPS)  # 视频帧率30
# print("video_fps_1:{}".format(video_fps_1)


 

你可能感兴趣的:(opencv,音视频,人工智能)