Ask Your Question
0

VideoWriter problem in Windows 7

asked 2014-01-02 19:02:11 -0600

unxnut gravatar image

updated 2014-01-02 19:12:48 -0600

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-01-02 19:55:26 -0600

Dong-Chan Cho gravatar image

change "CV_FOURCC('M', 'J', 'P', 'G')" to -1. then you can select codecs installed in your computer.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-01-02 19:02:11 -0600

Seen: 2,273 times

Last updated: Jan 02 '14