如下所示:

#获得视频的格式
videoCapture = cv2.VideoCapture(\'/home/lw/3661.mp4\')
 
#获得码率及尺寸
fps = videoCapture.get(cv2.CAP_PROP_FPS)
size = (int(videoCapture.get(cv2.CAP_PROP_ _WIDTH)), 
 int(videoCapture.get(cv2.CAP_PROP_ _HEIGHT)))
fNUMS = videoCapture.get(cv2.CAP_PROP_ _COUNT)
 
 
#读帧
success,   = videoCapture.read()
while success :
 cv2.imshow(\'windows\',  ) #显示
 cv2.waitKey(1000/int(fps)) #延迟
 success,   = videoCapture.read() #获取下一帧
 
videoCapture.release()

以上这篇python opencv读mp4视频的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

收藏 打印