I tried lot of combinations in opencv 2.3 and 2.4 to get frame count of a video, but without any result. It seems it simply isn't there.
stream = cv.VideoCapture(avsfilename) #stream.isOpened() returns True, everything's ok
framecount = cv.GetCaptureProperty(stream, CV_CAP_PROP_FRAME_COUNT) #no
framecount = cv.GetCaptureProperty(stream, cv.CV_CAP_PROP_FRAME_COUNT) #no
framecount = stream.get(cv.CV_CAP_PROP_FRAME_COUNT) #no
framecount = stream.get(CV_CAP_PROP_FRAME_COUNT) #no
'module' object has no attribute 'CV_CAP_PROP_FRAME_COUNT'
Anyone passed something similar?
You've got to be a little careful of your cv2
and cv
imports, both of these work:
import cv2
import cv2.cv as cv
#Using cv2:
stream = cv2.VideoCapture(filename)
print stream.get(cv.CV_CAP_PROP_FRAME_COUNT)
#using cv:
stream = cv.CaptureFromFile(filename)
print cv.GetCaptureProperty(stream, cv.CV_CAP_PROP_FRAME_COUNT)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With