I'm using OpenCV to do some processing on an AVI file. Everything is working fine, except for the fact that only a small fraction of the frames in the original video are being captured.
Here's an excerpt of my code:
capture=cvCaptureFromAVI(PATH_TO_VIDEO);
int fps=(int) cvGetCaptureProperty(capture,CV_CAP_PROP_FPS);
int frames=(int) cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_COUNT);
qDebug("%d frames at %d fps",frames,fps);
int framesSaved=0;
while(1) {
frame=cvQueryFrame(capture);
if(!frame) break;
framesSaved++;
data = (uchar *)frame->imageData;
//PROCESSING
cvWriteFrame(writer,frame);
}
cvReleaseVideoWriter(&writer);
qDebug("VIDEO SAVED: %d frames",framesSaved);
The output:
1948 frames at 50 fps
VIDEO SAVED: 105 frames
Any idea what the problem could be?
Thanks
NULL
from cvQueryFrame needs not mean EOF. Maybe the file is damaged / incomplete.