Ask Your Question
0

VideoWriter produces empty wmv

asked 2015-06-04 18:24:14 -0600

bear35645 gravatar image

I am attempting to write to a wmv file, but the following code produces a empty file.

Mat frame;
m_cam->read(frame);
imshow("Stimulus Mode", frame);
if(m_recording && m_videoFile != NULL){
    m_videoFile->write(frame);
}

The code that opens the file is:

            m_videoFile = new VideoWriter(fname, CV_FOURCC('W', 'M', 'V', '2'), 25, Size(640, 480), true);
        if(!m_videoFile->isOpened()){
            m_videoFile->open(fname, CV_FOURCC('W', 'M', 'V', '2'), 25, Size(640, 480), true);
        }

Then when I close it here:

    if(m_videoFile != NULL){
       m_videoFile->release();
       m_videoFile = NULL;\
    }

I am using openCV3.0 on Windows 32 bit and using MSVC2013 compiler.

imShow is displaying the video as I am expecting.

Thanks in advance, Bear

edit retag flag offensive close merge delete

Comments

I noticed that in Windows my output videos would be of size 0 when I didn't had the codec or even using some options from the codec settings. There is not such problem when a codec pack is installed, thought.

R.Saracchini gravatar imageR.Saracchini ( 2015-06-05 03:26:12 -0600 )edit

pklab, you can promote your comment as the answer. It turned out to be the image size.

bear35645 gravatar imagebear35645 ( 2015-06-05 09:20:57 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-06-05 03:17:41 -0600

pklab gravatar image

updated 2015-06-05 03:18:17 -0600

Is your image size same of video size ? Is your codec correctly installed in your system ? You can try to use -1 as fourcc ? this will brings a pop up with the codec setting from your os when you create the videowriter obj. Select your codec and try if it works. In case check the fourcc code in the created file.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-06-04 18:24:14 -0600

Seen: 3,471 times

Last updated: Jun 04 '15