Mp4 reading
hi I am new o opencv with python. I have installed OpenCV 2.4.1 and python 2.7 . I also make a short program that reads the avi file successfully. However it fails to read mp4 file. Below is my program . Will appreciate any suggestion.
import cv2
import cv2.cv as cv
c= cv2.VideoCapture("f:\\aviwork\\Example2.Mp4")
print c.grab() // returns false. however returns true if use avi file.
cap = cv.CaptureFromFile("f:\\aviwork\\Example2.Mp4")
nframes=int(cv.GetCaptureProperty(cap,cv.CV_CAP_PROP_FRAME_COUNT))
fps= int(cv.GetCaptureProperty(cap,cv.CV_CAP_PROP_FPS))
print "total frame",cv.GetCaptureProperty(cap,cv.CV_CAP_PROP_FRAME_COUNT)
print "fps" ,fps
print " currpos of videofile",cv.GetCaptureProperty(cap,cv.CV_CAP_PROP_POS_MSEC)
waitpermillisecond=int(1*1000/fps)
print "waitpermillisecond",waitpermillisecond
print cv.GetCaptureProperty(cap,cv.CV_CAP_PROP_FOURCC)
for f in xrange(nframes):
frameimg=cv.QueryFrame(cap)
print " currpos of videofile",cv.GetCaptureProperty(cap,cv.CV_CAP_PROP_POS_MSEC)
print " index of frame",cv.GetCaptureProperty(cap,cv.CV_CAP_PROP_POS_FRAMES)
cv.ShowImage("hcq",frameimg)
cv.WaitKey(1)
cv.DestroyAllWindows("hcq")
I had same problem before, have you try install ffmpeg or copy all file in c:\opencv\sources\3rdparty\ffmpeg to c:\python?