OpenCV2.4.13 Python VideoCapture Fail 解決辦法
阿新 • • 發佈:2019-02-16
參考: 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 cv2
cap = 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"
可以使用了: