hi I am new o opencv with python. I have installed python 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")