Tworzenie wideo z obrazów za pomocą OpenCV 2.4.1 w Ubuntu

Oto mój przykładowy program do tworzenia wideo z obrazów z OpenCV. Ale moje wideo wyjściowe nie działa i Wystąpił błąd, stwierdzając, że „Nie można demultipleksować strumienia” Proszę o pomoc.

  #include<cv.h>
  #include<highgui.h>
  #include<cvaux.h>
  #include<cxcore.h>

  int main()
{
    //CvVideoWriter *writer = 0;
    int isColor = 1;
    int fps     = 25;  // or 30
    int frameW  = 320; // 744 for firewire cameras
    int frameH  = 240; // 480 for firewire cameras
    CvSize size;

    size.width = frameW;
    size.height = frameH;
    CvVideoWriter *writer = cvCreateVideoWriter(
            "data3.avi",
            CV_FOURCC('M','J','P','G'),
            fps,
            size);
    IplImage* img = 0; 
    img=cvLoadImage("IMG_0157.JPG");
    for(int counter=0;counter < 3000;counter++)
    {
    cvWriteFrame(writer,img);      // add the frame to the file
    }
    cvReleaseVideoWriter(&writer);
    return 0;
}

questionAnswers(3)

yourAnswerToTheQuestion