# coding=gbk
import time
import cv2
cap = cv2.VideoCapture("D:\\jc\\Myself\\video\\Hacker_glasses_07_Videvo.mov")  # 读取文件
# 获取视频宽度
frame_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
# 获取视频高度
frame_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = cap.get(cv2.CAP_PROP_FPS) #视频平均帧率
while (True):
    ret, frame = cap.read()
    src = cv2.resize(frame, (frame_width // 2, frame_height // 2), interpolation=cv2.INTER_CUBIC)  # 窗口大小
    cv2.imshow("1", src) #让视频显示出来
    key = cv2.waitKey(1) & 0xFF
    if key == ord('q'):
        break
    time.sleep(1 / fps)  # 按原帧率播放

 

posted on 2023-06-04 20:38  大话人生  阅读(102)  评论(0编辑  收藏  举报