Ask Your Question

Revision history [back]

VideoWrite problem in Windows 7

I have a simple application that reads a video (an AVI file) and displays it. I wanted to communicate the results to a colleague and so, I tried to use VideoWriter class to save a video. I have gone through all the questions on this forum related to VideoWriter but drawn a blank. My problem is that VideoWriter creates a file but the file size is 0. It does not even seem to write a header into the file.

One question suggested that the system may be missing a codec but how do I find that out? I am working in Windows 7. I did go out and downloaded the codec package at fourcc which also installed a bunch of bloatware but that has not helped either.

The relevant portions of the code are:

cv::VideoWriter proc_video ( PROCESSED_VIDEO, CV_FOURCC('M','J','P','G'), frame_rate, frame.size() );
if ( ! proc_video.isOpened() )
    throw ( std::string ( "Could not open video file " ) + PROCESSED_VIDEO + " to write" );

Then, inside the loop, I have the following to write into the file:

proc_video.write ( frame );

After loop termination, I do proc_video.release();.

Can someone see what am I doing wrong? I have already spent about four hours trying to make sense of this simple code.

VideoWrite VideoWriter problem in Windows 7

I have a simple application that reads a video (an AVI file) and displays it. I wanted to communicate the results to a colleague and so, I tried to use VideoWriter class to save a video. I have gone through all the questions on this forum related to VideoWriter but drawn a blank. My problem is that VideoWriter creates a file but the file size is 0. It does not even seem to write a header into the file.

One question suggested that the system may be missing a codec but how do I find that out? I am working in Windows 7. I did go out and downloaded the codec package at fourcc which also installed a bunch of bloatware but that has not helped either.

The relevant portions of the code are:

cv::VideoWriter proc_video ( PROCESSED_VIDEO, CV_FOURCC('M','J','P','G'), frame_rate, frame.size() );
if ( ! proc_video.isOpened() )
    throw ( std::string ( "Could not open video file " ) + PROCESSED_VIDEO + " to write" );

Then, inside the loop, I have the following to write into the file:

proc_video.write ( frame );

After loop termination, I do proc_video.release();.

Can someone see what am I doing wrong? I have already spent about four hours trying to make sense of this simple code.