I've been reviewing the multitudes of similar questions for this issue, but I'm afraid I just cannot figure out why I cannot open a file in opencv
I have a file "small.avi", which is a reencoding of "small.mp4" that I got from the internet. I reencoded it with ffmpeg -i small.mp4 small.avi, and I did this because I couldn't open a mp4 file either and online it recommended trying an avi format first.
Here is my code (mostly copied from a tutorial, with a few lines to show some relevant info):
import cv2
import os
for _, __, files in os.walk("."):
for file in files:
print file
print ""
cap = cv2.VideoCapture("small.mp4")
print cap.isOpened()
print cap.open("small.avi")
i = 0
while cap.isOpened() and i < 10:
i += 1
ret, frame = cap.read()
print "read a frame"
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame', gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
This produces the following output:
"A:\Program Files\AnacondaPY\Anaconda\python.exe" A:/Documents/Final/VideoProcessor.py
small.avi
small.mp4
VideoProcessor.py
False
False
Process finished with exit code 0
My program does not appear to properly open either file. Following the advice of
Can not Read or Play a Video in OpenCV+Python using VideoCapture
and
Cannot open ".mp4" video files using OpenCV 2.4.3, Python 2.7 in Windows 7 machine,
I found my cv2 version to be 3.0.0, went to
A:\Downloads\opencv\build\x86\vc12\bin
and copied the file opencv_ffmpeg300.dll to
A:\Program Files\AnacondaPY\Anaconda
Despite this, the code still does not successfully open the video file. I even tried the x64 versions, and tried naming the file opencv_ffmpeg.dll, opencv_ffmpeg300.dll, and opencv_ffmpeg300_64.dll (for the x64 version). Is there anything else I can try to fix this?
Thanks for any help