Ask Your Question

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

asked 2014-01-08 07:52:41 -0500

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

berak gravatar image

This is a copy of the question:

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. lImg );
    lVidWrt.write( lImg );

// This is not required according to the doc...
  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!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2014-01-10 00:19:45 -0500

There were some synchronization issue in OpenCV 2.4.6 and may be earlier releases. It had been fixed in 2.4.7 or 2.4.8 release, but we did not get response from issue author. Could you update OpenCv up to 2.4.8 and check the issue status. If it`s fixed, I close the issue.

edit flag offensive delete link more


My issue doesn't look like the one you are referring to. Actually, I experience no syncing problem when my capture application is started via a php script on my server. I experience sometimes syncing problems when I launch it from the command line. The first thing I will try is to call it directly on my host, not in VirtualBox. After some reflections, I suspect a syncing problem with the virtual disk. I'll let you know here.

dom_beau gravatar imagedom_beau ( 2014-01-10 09:37:31 -0500 )edit

answered 2014-01-13 22:28:42 -0500


After few tests, I definitely would not push further the investigation. I got an "invalid" .avi file, then waited for ~10 seconds, then tried to re-read it again and all was correct.

IMHO, the problem is in the way VirtualBox synchronizes its virtual disks. I won't worry much more about this issue.

Thanks Alexander Smorkalov for the help anyway.

Dominique Beauchamp

edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2014-01-08 07:52:41 -0500

Seen: 444 times

Last updated: Jan 13 '14