Yamaneko
Yamaneko

Reputation: 3563

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?

Upvotes: 0

Views: 1156

Answers (1)

Andrey Kamaev
Andrey Kamaev

Reputation: 30122

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.

Upvotes: 1

Related Questions