cv2.VideoCapture : can not read saved videos
My problem is the same as mentioned in
http://answers.opencv.org/question/1965/cv2videocapture-cannot-read-from-file/
and
https://stackoverflow.com/questions/11699298/opencv-2-4-videocapture-not-working-on-windows
Im using OpenCV 3.4.0 on Windows 10, able to capture live videos from Webcam using cv2.VideoCapture(0) but can not read my pre-existing .mp4/.avi/.3gp videos.
Yes, I have given the entire path correctly, even changed to '/' , copied the 'opencv_ffmpeg340_64.dll' file into C:\Python27 and yet no results.
I read a suggestion to use the OpenCV binaries from http://www.lfd.uci.edu/~gohlke/python... , but do not know exactly how to proceed.
The same question was asked in 2012 (http://answers.opencv.org/question/19...) and no body seems to have benefitted from any solution, hence beginning a new thread.
edit
heres my code:
import cv2
import numpy as np
cap = cv2.VideoCapture('C:\Users\DELL PC\Desktop\IMG_PROC\python\VID-20140623-WA0000.avi') # cap = cv2.VideoCapture('C:/Users/DELL PC/Desktop/IMG_PROC/python/VID-20140623-WA0000.avi')
Check if camera opened successfully
if (cap.isOpened()== False):
print("Error opening video stream or file")
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
cv2.imshow('Frame',frame)
if cv2.waitKey(25) & 0xFF == ord('q'):
break
else:
break
cap.release()
cv2.destroyAllWindows()
"copied opencv_ffmpeg340_64.dll' file into C:\Python27" -- no, put it on the PATH, instead of copying dlls around
@berak , i have placed the dll file in the same folder as the video, yet no results
with opencv 340 you will need openh264-1.7.0-win64.dll too
hey @LBerger, still no luck. I copied openh264-1.7.0-win64.dll into C:\Python27 and the file containing video to be read.
"i have placed the dll file in the same folder as the video" : no you can copy in same folder that python.exe or in folder python2_7/scripts (check if this two folders are in path : use cmd and in console type set, you will see all system variables and check path variable)
Yes i have put them in C:\Python27(where python.exe exists) and C:\Python27\Scripts. Still nothing. can you please elaborate on what you mean by 'check if this two folders are in path' ?
@LBerger, I have checked the pat variables and both opencv and python do exist
I got exactly the same problem. Do not know what to do with it.
@ouyangivan , please do NOT post answers here, if you have a question or comment, thank you.