I am trying to count total number of Frames in my video file ('foo.h264').
>>> import numpy as nm
>>> import cv2
>>> cap = cv2.VideoCapture('foo.h264')
>>> cap.get(CV_CAP_PROP_FRAME_COUNT)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'CV_CAP_PROP_FRAME_COUNT' is not defined
>>> cap.get(5)
25.0
>>> cap.get(7)
-192153584101141.0
So I think get(5)
is giving frame rate and get(7)
gives total number of frames. Obviously get(7)
is incorrect in the above case. So I tried to find these values in an .avi
file.
>>> cap = cv2.VideoCapture('foo.avi')
>>> cap.get(5)
29.97002997002997
>>> cap.get(7)
256379.0
I can calculate the total number of frames by multiplying FPS
by duration of the video, but I'm not sure if the FPS given for .h264
is right or not. Why does it give negative number of total frames? Is this a bug?
P.S: I recorded this video file using raspberry pi camera.