Python calls opencv to get the width and height of the video

import time

import cv2

cap = cv2.VideoCapture("D:\\jc\\Myself\\video\\Hacker_glasses_07_Videvo.mov") # read file

# get video width

frame_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))

# get video height

frame_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))

fps = cap.get(cv2.CAP_PROP_FPS) #Video average frame rate

while (True):

ret, frame = cap.read()

src = cv2.resize(frame, (frame_width // 2, frame_height // 2), interpolation=cv2.INTER_CUBIC) # window size

cv2.imshow("1", src) #Let the video display

key = cv2.waitKey(1) & 0xFF

if key == ord('q'):

break

time.sleep(1 / fps) # Play at the original frame rate

Guess you like

Origin blog.csdn.net/jiulinghouxiao/article/details/128543058