VideoWriter VideoCapture and uncompressed AVI

asked 2012-10-30 18:34:56 -0600

GP gravatar image

Hi everyone,

I think a similar issue is reported in a previous unanswered discussion. But I prefer to report my issue with more details. Anyway, I have a problem with cv::VideoCapture when grabbing frames from an uncompressed AVI file created using cv::VideoWriter. Basically the video seems ok when it's played with WMP for instance, but the frames are corrupted when grabbed using cv::VideoCapture (a snapshot here).

I'm using OpenCV 2.4.1, built in Windows 7 using Visual Studio 2010, x86, WITH_VIDEOINPUT=ON and WITH_FFMPEG=OFF. Here's a quick code sample:

int main()
    VideoCapture camera(0);
    VideoWriter writer("test.avi", 0, 30.0, Size(640, 480), true);

    int count = 0;
    while (count++ < 90)
        Mat frm;
        camera >> frm;
        writer << frm;
        imshow("Frame recorded", frm);


    VideoCapture video("test.avi");
    Mat frm;
    while (
        imshow("Frame grabbed", frm);
    return 0;

I checked the issue tracker, and the change-log of the latest version, but this problems seems not to be mentioned. So, I suppose I'm missing something. Any help is appreciated! Thanks in advance,


edit retag flag offensive close merge delete


I have the same problem.

adahbingee gravatar imageadahbingee ( 2012-11-08 04:14:15 -0600 )edit

It seems no one has an easy solution. It's an annoying problem. At least I would like to understand if it's a common problem or if it depends on the specific OpenCV configuration.

GP gravatar imageGP ( 2012-11-09 16:49:45 -0600 )edit

Same problem but no solution, for me it should be a bug.

Pierre gravatar imagePierre ( 2012-11-23 02:02:14 -0600 )edit

Unfortunately a longstanding bug

rbiro gravatar imagerbiro ( 2013-05-22 11:39:09 -0600 )edit

rbiro, the link you posted seems to report a different issue. I having the same problem as reported here, when I try to read an uncompressed AVI (DIB ) fourCC. I don't see the crash reported in the previous link. They claim they just fixed the issue by updating ffmpeg to the latest version, but I don't see why. From my initial debugging, this has nothing to do with FFMpeg and the bug seems to be in cap_vfw.cpp. I don't see how updating ffmpeg can fix the issue as I see the bug when using the Windows API code path. Do you agree? Thanks.

Chris_c gravatar imageChris_c ( 2013-10-25 10:11:37 -0600 )edit