0

I have the following code which writes a few frames to a .avi video file. This works perfectly fine on a windows machine but when I try it on my Mac it creates the .avi file and displays no errors, but the file will not play. I haven't been able to find a clear solution so far. I am currently using Mac OSX 10.9.2.

void videoWriter()
{
    CvVideoWriter *writer;
    writer = cvCreateVideoWriter("test.avi",CV_FOURCC('I','Y','U','V'),1,Size(640,480),1);

    for(int i = 0; i < 9; i++)
    {
        if(imMan.returnSelect(i)) {
            cout << "Frame " << i << endl;
            /****** Original Image *********/
            Mat frame = imMan.returnOrg(i);
            IplImage fr = frame;
            cvWriteFrame(writer,&fr);
        }
    }

    cvReleaseVideoWriter(&writer);
}
Tom smith
  • 670
  • 2
  • 15
  • 31

2 Answers2

0

what is the size of frame?

In my experience, cvWriteFrame will not generate error even if the 4th parameter of cvCreateVideoWriter does not match with the dimension of your image frame. And it write something like an header. (with 414 byte...)

make sure they match exactly.

lanpa
  • 1,319
  • 9
  • 12
0

You have to use the right combination of codec and extension.

The codec is platform dependent. That could be the problem.

Try using this combination:

writer = cvCreateVideoWriter("test.mkv",CV_FOURCC(*'X264),1,Size(640,480),1);

Here is the reference link

Community
  • 1
  • 1
Revanth Kausikan
  • 673
  • 1
  • 9
  • 21