Write a test: OpenCV does not read the last 3-4 frames from an AVI file (Bug #3650)


Added by Vasil Khalidov almost 11 years ago. Updated almost 11 years ago.


Status:Cancelled Start date:2014-04-15
Priority:Normal Due date:
Assignee:Vasil Khalidov % Done:

0%

Category:highgui-video
Target version:-
Affected version:pre 2.4 (deprecated) Operating System:Linux
Difficulty: HW Platform:x64
Pull request:

Description

This bug was observed for OpenCV v.2.3.1, default for Ubuntu 12.10 (quantal). I currently can't report if it is reproducible in later versions of OpenCV.

When opening a video capture from AVI file, the CV_CAP_PROP_FRAME_COUNT contains the correct number of frames in the video (10 in the example below). However, when reading the frames one by one using the cvQueryFrame() method, the last 3 or 4 frames are not returned (only 7 frames are returned in the example below).

Here's the code snippet to reproduce the bug:

    CvCapture * capture = cvCaptureFromFile("video_test1.avi");
    int frame_count = static_cast<int>(cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_COUNT));
    cout << frame_count << endl;
    const IplImage * frame;
    for (int i = 0; i < frame_count; ++i) {
        frame = cvQueryFrame(capture);
        assert(frame);
        cout << i << " ";
    }
    cout << endl;
    cvReleaseCapture(&capture);

Expected output:
10
0 1 2 3 4 5 6 7 8 9

Observed output:
10
0 1 2 3 4 5 6 <assertion error>

The test file used as an input (AVI file, Codec: MPEG-4 Video, DIVX) is in the attachment.

Other file formats for which the bug could be reproduced: MP4 file, Codec: H264 - MPEG-4 AVC (part 10) (avc1)


video_test1.avi (7.7 kB) Vasil Khalidov, 2014-04-15 12:33 pm


Associated revisions

Revision fdf31ec1
Added by Vadim Pisarevsky about 10 years ago

Merge pull request #3650 from StevenPuttemans:fix_tutorials_master

History

Updated by Jose Gómez almost 11 years ago

The test video works fine with OpenCV 2.4.8 (using the Java wrapper). 9 frames processed.

Updated by Evgeny Talanin almost 11 years ago

Vasil, thanks for reporting.
I confirm Jose's observation that your sample works pretty well on Ubuntu 12.04 with the last OpenCV version (2.4.8).
To be sure this problem won't re-appear you can write a test based on this code that checks how many frames were loaded. And after doing this propose it as a pull request as described at http://code.opencv.org/projects/opencv/wiki/How_to_contribute

  • Assignee set to Vasil Khalidov

Updated by Andrew Senin almost 11 years ago

  • Subject changed from OpenCV does not read the last 3-4 frames from an AVI file to Write a test: OpenCV does not read the last 3-4 frames from an AVI file
  • Status changed from New to Open

Updated by Steven Puttemans almost 11 years ago

This should be cancelled right? The bug report should only be reopened if it continues in OpenCV 2.4.9.
Also, please do take in mind that using outdated C-API will never guarantee success. Do use the C++-API instead.

  • Status changed from Open to Cancelled

Also available in: Atom PDF