简体   繁体   中英

cvQueryFrame() returns NULL before end of file

I'm trying to process large AVI files (approx. 61000 frames, 505MB) with OpenCV, using cvCaptureFromAVI() and cvQueryFrame() .

However, cvQueryFrame() returns a NULL pointer before it reaches the last frame of the avi.

long int numframe = 6000;
while (numframe < 67000)
{        
    frame = cvQueryFrame( capture );
    if (! frame)
    {
        fprintf(stderr, "could not query the frame %ld.\n", numframe);
        break;
    }

    char namefile[250];
    sprintf( namefile, "/media/6E86F8CB03A4DFA4/image-sequence/%ld.jpg", numframe );
    cvSaveImage( namefile, frame ); // save frame as a image

    numframe++;
}

Has anyone else has had the same problem and found a way around it? Is there something that I can do?

Most probably you are experienced one of the FFMPEG integration bugs. This bugreport looks very similar to your problem.

What version of OpenCV are you using?

Any way I recommend you:

  1. Try another version of OpenCV

  2. Try to build OpenCV without FFMPEG. Probably OpenCV will be able to read your file with VfW or GStreamer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM