Criando Vídeo a partir de Imagens com o OpenCV 2.4.1 no Ubuntu

Aqui está o meu programa de amostra para criar vídeo a partir de imagens com o OpenCV. Mas meu vídeo de saída não está funcionando e ocorreu um erro informando que "Não foi possível demultiplexar stream" Por favor, ajude.

  #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