avatar

python调用opencv播放mp4文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# -*- coding: UTF-8 -*-
import cv2
videoCapture = cv2.VideoCapture('test/sp.mp4')

fps = videoCapture.get(cv2.CAP_PROP_FPS)
size = (int(videoCapture.get(cv2.CAP_PROP_FRAME_WIDTH)),
int(videoCapture.get(cv2.CAP_PROP_FRAME_HEIGHT)))
fNUMS = videoCapture.get(cv2.CAP_PROP_FRAME_COUNT)

success, frame = videoCapture.read()
while success:
cv2.namedWindow("windows", 0)
cv2.resizeWindow("windows", 866, 486)#指定窗口大小
cv2.imshow('windows', frame)
cv2.waitKey(1000/int(fps))
success, frame = videoCapture.read()
if cv2.waitKey(1) & 0xFF == ord('q'):
break

videoCapture.release()

评论