参考: http://blog.csdn.net/whai362/article/details/52589206#comments
把OpenCV下ffmpeg中所有的文件拷贝到python27下,在我电脑下ffmpeg的目录D:\IDE\opencv\sources\3rdparty\ffmpeg,python27的目录为D:\IDE\Python27.
最后,因为我用的是opencv2.4.13,且python是64位的,所以我需要把opencv_ffmpeg_64.dll修改为opencv_ffmpeg2413_64.dll然后就搞定了。如果是python是32位的话,应该要修改opencv_ffmpeg.dll为opencv_ffmpeg版本号.dll即可。
# -*- coding: utf-8 -*-
import numpy as np
import cv2cap = cv2.VideoCapture(r'1.avi')if cap.isOpened():print "Open Success"# 获得码率fps = cap.get(cv2.cv.CV_CAP_PROP_FPS)# 读帧success, frame = cap.read()while success:cv2.imshow("Oto Video", frame) # 显示cv2.waitKey(1000 / int(fps)) # 延迟success, frame = cap.read() # 获取下一帧
else:print "Open False"
可以使用了: