python opencv獲取視頻基本信息

video_path = "./test0.mp4"
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))  # (540, 960)
# 視頻總幀數
total_frames = int(video_capture.get(cv2.CAP_PROP_FRAME_COUNT))  # 799
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))
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章