(python) VideoCapture() returns zero for all CV cap props
Hello everybody,
I am trying to create a plot as overlay in my video (uisng openCV and matplotlib). The first thing would be to detect the frames of the video. This is what I am trying to do:
cap = cv2.VideoCapture('C:/PyDev/workspace/MyProject/src/files/video.mp4')
pos_frame = cap.get(cv2.cv.CV_CAP_PROP_POS_FRAMES)
Using the debugger, the variable cap hold the value
VideoCapture: <VideoCapture 000000000425D310>
but the value of pos_frame is 0.0.
I already tried other videos and other formats. Also I installed the K-Lite Codec Pack. Unfortunately it didn't help. I don't really understand if the video is loaded successfully (I think yes, as cap is not empty). Also calling
cap.grab()
retuns False.
Does anyone know how to solve this problem?
Not sure what you did here
VideoCapture: <VideoCapture 000000000425D310>
, but did you already tried visualising the frames first?1st thing: please check, if your video was loaded:
cap.isOpened() == True
(the VideoCapture object itself will always be valid, video loaded or not)
@StevenPuttemans: This is just the value of the cap variable during runtime. I can't visualize the frames, as the video seems not to be loaded correctly. @berak: Thanks, I tried it and
isOpened()
returnsFalse
. Which means there is a problem loading the video. The path is correct. What else could I try?to rule out a codec issue, could you try one of the vids from opencv/samples/data ? e.g. the 768x576.avi ?
(if that works, you know, it's a mp4 problem, and you have to hunt for codecs to install.
Thank you very much @berak. By using the sample video I could find out, that this is a codec problem. Installed K-Lite Codec Pack and Windows 7 Codec Pack but unfortunetaly it didn't help. Can you give an advice, in which direction i should go with my research?