如下所示:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#获得视频的格式 videocapture = cv2.videocapture( '/home/lw/3661.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.imshow( 'windows' , frame) #显示 cv2.waitkey( 1000 / int (fps)) #延迟 success, frame = videocapture.read() #获取下一帧 videocapture.release() |
以上这篇python opencv读mp4视频的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/liuweizj12/article/details/80235065