Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
  1. you overwrite your avi with each call to cvCreateVideoWriter, so move it out of the loop
  2. you never call cvWriteFrame() , so it'll be empty anyway.

   size = cvSize(
         (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH),
         (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT)
   );
   fps = cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
   writer = cvCreateVideoWriter(
                "Live Stream",
                CV_FOURCC('M', 'J', 'P', 'G'),
                fps,
                size,
                1
            );
   while(1)
   {
       IplImage* frame = cvQueryFrame(capture);

       if(!frame)
           break;

       cvWriteFrame(writer,frame);

       cvShowImage("Live Stream", frame);          
       c = cvWaitKey(33);
       if(c == 27)
       {
           cvReleaseVideoWriter(&writer);
           break;
       }    
   }

(and promise, to use the c++ api, the next time ;)