Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

videowriter writes only 128 bytes files

I thought i would ask here as well. http://stackoverflow.com/questions/36319366/opencv-video-writer-only-writes-128byte-files-os-x-el-capitan

Whenever i want to write a movie videowriter only writes files of 128 bytes on Mac. I tried almost every codec. Does anyone have a mac and can they use below examples to see if it works for them?

Many thanks, atv

#include <opencv2 opencv.hpp="">
#include <opencv2 highgui="" highgui.hpp="">

int main( int argc, char** argv ) {
CvCapture* capture;

capture = cvCreateCameraCapture(0);

assert( capture != NULL );

IplImage* bgr_frame = cvQueryFrame( capture );

CvSize size = cvSize(
                     (int)cvGetCaptureProperty( capture,
                                               CV_CAP_PROP_FRAME_WIDTH),
                     (int)cvGetCaptureProperty( capture,
                                               CV_CAP_PROP_FRAME_HEIGHT)
                     );

cvNamedWindow( "Webcam", CV_WINDOW_AUTOSIZE );

CvVideoWriter *writer = cvCreateVideoWriter(    "vidtry.AVI",
                                            CV_FOURCC('A','V','C','1'),
                                            30,
                                        size
                                            );

while( (bgr_frame = cvQueryFrame( capture )) != NULL ) 
{
     cvWriteFrame(writer, bgr_frame );
     cvShowImage( "Webcam", bgr_frame );
     char c = cvWaitKey( 33 );
     if( c == 27 ) break;
}
cvReleaseVideoWriter( &writer );
cvReleaseCapture( &capture );
cvDestroyWindow( "Webcam" );
return( 0 );
}