I am new to OpenCV and after reading a lot of posts, I figured out how to get the number of frames in a video by using the following code. All my videos are about 30 seconds long each. However, OpenCV's frame count method always returns 0. I am not sure why. My video type is .mp4 . Can someone help me with this?
I tried using the same code for different length videos. In all these cases, it printed 0 as the frame count.
My OpenCV version is 2.4.11
Here is the code snippet.
import cv2
cap = cv2.VideoCapture("video.mp4")
length = int(cap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT))
print( length )
Thank you!