Ask Your Question

Revision history [back]

AVI file created by OpenCV 2.4.6 not always valid when app exits

This is a copy of the question: http://stackoverflow.com/questions/20987800/avi-file-created-by-opencv-2-4-6-not-always-valid-when-app-exits


I'm currently using OpenCV 2.4.6 with gcc 4.7.3 on Lubuntu x64. To view the AVI I use gnome-mplayer 1.0.8 (installed with Lubuntu). All the kit is running on a VM in VirtualBox.

I use the common code suite to grab images then add them to the VideoWriter. In a (second) thread, I do this:

cv::Mat lImg;
cv::VideoCapture lVidCap( 0 );
cv::VideoWriter lVidWrt( lFileName, CV_FOURCC( 'M', 'J', 'P', 'G' ), 15, cv::Size( 640, 480 ) );

while ( true )
{
    // Here check if we must quite the loop.

    lVidCap.read( lImg );
    lVidWrt.write( lImg );
}

// This is not required according to the doc...
lVidWrt.release();
  1. It works correctly sometimes.

  2. On other times, I have to wait for many seconds before the file is valid (despite it is indicated that it takes many Mb, in gnome-mplayer it is written 0k).

Why is the file not always available as soon as the VideoWriter is destroyed?

If you have any suggestion, I would like to read it! ;-) Thanks!

click to hide/show revision 2
retagged

updated 2014-01-08 07:55:42 -0600

berak gravatar image

AVI file created by OpenCV 2.4.6 not always valid when app exits

This is a copy of the question: http://stackoverflow.com/questions/20987800/avi-file-created-by-opencv-2-4-6-not-always-valid-when-app-exits


I'm currently using OpenCV 2.4.6 with gcc 4.7.3 on Lubuntu x64. To view the AVI I use gnome-mplayer 1.0.8 (installed with Lubuntu). All the kit is running on a VM in VirtualBox.

I use the common code suite to grab images then add them to the VideoWriter. In a (second) thread, I do this:

cv::Mat lImg;
cv::VideoCapture lVidCap( 0 );
cv::VideoWriter lVidWrt( lFileName, CV_FOURCC( 'M', 'J', 'P', 'G' ), 15, cv::Size( 640, 480 ) );

while ( true )
{
    // Here check if we must quite the loop.

    lVidCap.read( lImg );
    lVidWrt.write( lImg );
}

// This is not required according to the doc...
lVidWrt.release();
  1. It works correctly sometimes.

  2. On other times, I have to wait for many seconds before the file is valid (despite it is indicated that it takes many Mb, in gnome-mplayer it is written 0k).

Why is the file not always available as soon as the VideoWriter is destroyed?

If you have any suggestion, I would like to read it! ;-) Thanks!