CvVideoWriter Not Writing

I was trying to write a video to a file using the CvVideoWriter structure, but nothing was being written. I received no errors, nothing. The program would run, everything would go as expected, but the video would not write. This was my code.

..... more code here .....

CvVideoWriter *writer = cvCreateVideoWriter( argv[ 1 ],
                         CV_FOURCC('R','I','F','F'),
                         70,
                         size
                         );

..... more code here .....

cvWriteFrame( writer, bgr_frame );

..... more code here .....

After a bit of testing, what hinted me to the problem was placing this code in my program

CvVideoWriter *writer = cvCreateVideoWriter( argv[ 1 ],
                         CV_FOURCC('R','I','F','F'),
                         70,
                         size
                         );
if ( writer == NULL )
	printf("writer is NULL\n");
if ( writer == false)
	printf("writer is false\n");

This lead me to believe that the cvCreateVideoWriter function was returning, false, to my writer stucture. So when cvWriteFrame was called it did nothing. I wanted to know why, so I looked through the source to find the definition of the cvCreateVideoWriter function, this is what I found.

CvVideoWriter* cvCreateVideoWriter( const char* filename,
                                    int fourcc,
                                    double fps,
                                    CvSize frameSize,
                                    int isColor )
{
CvVideoWriter_FFMPEG* writer = new CvVideoWriter_FFMPEG;
if(writer->open(filename, fourcc, fps, frameSize, isColor != 0))
     return writer;
delete writer;
return 0;
}

So I saw here that what was truly returning the NULL was the writer objects open() function, the next step was to hunt it down. After testing some of the function’s modules which returned a NULL pointer, this is what I found.

bool CvVideoWriter::open( const char * filename, int fourcc,
		double fps, CvSize frameSize, bool is_color )
{
        ..... code code code .....
        ..... code code code .....
	/* Lookup codec_id for given fourcc */
#if LIBAVCODEC_VERSION_INT<((51<<16)+(49<<8)+0)
    if((codec_id = codec_get_bmp_id( fourcc )) == CODEC_ID_NONE )
        return false;
#else
	const struct AVCodecTag * tags[] = { codec_bmp_tags, NULL};
    if((codec_id = av_codec_get_id(tags, fourcc)) == CODEC_ID_NONE)
        return false;
#endif
        ..... code code code .....
        ..... code code code .....
	return true;
}

This hint took me to my final conclusion. I decided to look through the codec support in OpenCV, I found this big list of codecs only to be disappointed that the codec I was putting into my function wasn’t listed here! So I replaced it with one on the list that was also on my computer. If you’re having this problem look through this list to see if your codec is here.

FIX: Just replace the codec with one of the codecs on this list, that is also on your computer.

typedef struct AVCodecTag {
    int id;
    unsigned int tag;
} AVCodecTag;

const AVCodecTag codec_bmp_tags[] = {
    { CODEC_ID_H264, MKTAG('H', '2', '6', '4') },
    { CODEC_ID_H264, MKTAG('h', '2', '6', '4') },
    { CODEC_ID_H264, MKTAG('X', '2', '6', '4') },
    { CODEC_ID_H264, MKTAG('x', '2', '6', '4') },
    { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') },
    { CODEC_ID_H264, MKTAG('V', 'S', 'S', 'H') },

    { CODEC_ID_H263, MKTAG('H', '2', '6', '3') },
    { CODEC_ID_H263P, MKTAG('H', '2', '6', '3') },
    { CODEC_ID_H263I, MKTAG('I', '2', '6', '3') }, /* intel h263 */
    { CODEC_ID_H261, MKTAG('H', '2', '6', '1') },

    /* added based on MPlayer */
    { CODEC_ID_H263P, MKTAG('U', '2', '6', '3') },
    { CODEC_ID_H263P, MKTAG('v', 'i', 'v', '1') },

    { CODEC_ID_MPEG4, MKTAG('F', 'M', 'P', '4') },
    { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', 'X') },
    { CODEC_ID_MPEG4, MKTAG('D', 'X', '5', '0') },
    { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'D') },
    { CODEC_ID_MPEG4, MKTAG('M', 'P', '4', 'S') },
    { CODEC_ID_MPEG4, MKTAG('M', '4', 'S', '2') },
    { CODEC_ID_MPEG4, MKTAG(0x04, 0, 0, 0) }, /* some broken avi use this */

    /* added based on MPlayer */
    { CODEC_ID_MPEG4, MKTAG('D', 'I', 'V', '1') },
    { CODEC_ID_MPEG4, MKTAG('B', 'L', 'Z', '0') },
    { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 'v') },
    { CODEC_ID_MPEG4, MKTAG('U', 'M', 'P', '4') },
    { CODEC_ID_MPEG4, MKTAG('W', 'V', '1', 'F') },
    { CODEC_ID_MPEG4, MKTAG('S', 'E', 'D', 'G') },

    { CODEC_ID_MPEG4, MKTAG('R', 'M', 'P', '4') },

    { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, /* default signature when using MSMPEG4 */
    { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') },

    /* added based on MPlayer */
    { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') },
    { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '5') },
    { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '6') },
    { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '4') },
    { CODEC_ID_MSMPEG4V3, MKTAG('A', 'P', '4', '1') },
    { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '1') },
    { CODEC_ID_MSMPEG4V3, MKTAG('C', 'O', 'L', '0') },

    { CODEC_ID_MSMPEG4V2, MKTAG('M', 'P', '4', '2') },

    /* added based on MPlayer */
    { CODEC_ID_MSMPEG4V2, MKTAG('D', 'I', 'V', '2') },

    { CODEC_ID_MSMPEG4V1, MKTAG('M', 'P', 'G', '4') },

    { CODEC_ID_WMV1, MKTAG('W', 'M', 'V', '1') },

    /* added based on MPlayer */
    { CODEC_ID_WMV2, MKTAG('W', 'M', 'V', '2') },
    { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'd') },
    { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'd') },
    { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'l') },
    { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '2', '5') },
    { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '1') },
    { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '2') },
    { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', '2') },
    { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'P', 'E', 'G') },
    { CODEC_ID_MPEG1VIDEO, MKTAG('P', 'I', 'M', '1') },
    { CODEC_ID_MPEG1VIDEO, MKTAG('V', 'C', 'R', '2') },
    { CODEC_ID_MPEG1VIDEO, 0x10000001 },
    { CODEC_ID_MPEG2VIDEO, 0x10000002 },
    { CODEC_ID_MPEG2VIDEO, MKTAG('D', 'V', 'R', ' ') },
    { CODEC_ID_MPEG2VIDEO, MKTAG('M', 'M', 'E', 'S') },
    { CODEC_ID_MJPEG, MKTAG('M', 'J', 'P', 'G') },
    { CODEC_ID_MJPEG, MKTAG('L', 'J', 'P', 'G') },
    { CODEC_ID_LJPEG, MKTAG('L', 'J', 'P', 'G') },
    { CODEC_ID_MJPEG, MKTAG('J', 'P', 'G', 'L') }, /* Pegasus lossless JPEG */
    { CODEC_ID_MJPEG, MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - decoder */
    { CODEC_ID_MJPEG, MKTAG('j', 'p', 'e', 'g') },
    { CODEC_ID_MJPEG, MKTAG('I', 'J', 'P', 'G') },
    { CODEC_ID_MJPEG, MKTAG('A', 'V', 'R', 'n') },
    { CODEC_ID_HUFFYUV, MKTAG('H', 'F', 'Y', 'U') },
    { CODEC_ID_FFVHUFF, MKTAG('F', 'F', 'V', 'H') },
    { CODEC_ID_CYUV, MKTAG('C', 'Y', 'U', 'V') },
    { CODEC_ID_RAWVIDEO, 0 },
    { CODEC_ID_RAWVIDEO, MKTAG('I', '4', '2', '0') },
    { CODEC_ID_RAWVIDEO, MKTAG('Y', 'U', 'Y', '2') },
    { CODEC_ID_RAWVIDEO, MKTAG('Y', '4', '2', '2') },
    { CODEC_ID_RAWVIDEO, MKTAG('Y', 'V', '1', '2') },
    { CODEC_ID_RAWVIDEO, MKTAG('U', 'Y', 'V', 'Y') },
    { CODEC_ID_RAWVIDEO, MKTAG('I', 'Y', 'U', 'V') },
    { CODEC_ID_RAWVIDEO, MKTAG('Y', '8', '0', '0') },
    { CODEC_ID_RAWVIDEO, MKTAG('H', 'D', 'Y', 'C') },
    { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '1') },
    { CODEC_ID_INDEO3, MKTAG('I', 'V', '3', '2') },
    { CODEC_ID_VP3, MKTAG('V', 'P', '3', '1') },
    { CODEC_ID_VP3, MKTAG('V', 'P', '3', '0') },
    { CODEC_ID_ASV1, MKTAG('A', 'S', 'V', '1') },
    { CODEC_ID_ASV2, MKTAG('A', 'S', 'V', '2') },
    { CODEC_ID_VCR1, MKTAG('V', 'C', 'R', '1') },
    { CODEC_ID_FFV1, MKTAG('F', 'F', 'V', '1') },
    { CODEC_ID_XAN_WC4, MKTAG('X', 'x', 'a', 'n') },
    { CODEC_ID_MSRLE, MKTAG('m', 'r', 'l', 'e') },
    { CODEC_ID_MSRLE, MKTAG(0x1, 0x0, 0x0, 0x0) },
    { CODEC_ID_MSVIDEO1, MKTAG('M', 'S', 'V', 'C') },
    { CODEC_ID_MSVIDEO1, MKTAG('m', 's', 'v', 'c') },
    { CODEC_ID_MSVIDEO1, MKTAG('C', 'R', 'A', 'M') },
    { CODEC_ID_MSVIDEO1, MKTAG('c', 'r', 'a', 'm') },
    { CODEC_ID_MSVIDEO1, MKTAG('W', 'H', 'A', 'M') },
    { CODEC_ID_MSVIDEO1, MKTAG('w', 'h', 'a', 'm') },
    { CODEC_ID_CINEPAK, MKTAG('c', 'v', 'i', 'd') },
    { CODEC_ID_TRUEMOTION1, MKTAG('D', 'U', 'C', 'K') },
    { CODEC_ID_MSZH, MKTAG('M', 'S', 'Z', 'H') },
    { CODEC_ID_ZLIB, MKTAG('Z', 'L', 'I', 'B') },
    { CODEC_ID_SNOW, MKTAG('S', 'N', 'O', 'W') },
    { CODEC_ID_4XM, MKTAG('4', 'X', 'M', 'V') },
    { CODEC_ID_FLV1, MKTAG('F', 'L', 'V', '1') },
    { CODEC_ID_SVQ1, MKTAG('s', 'v', 'q', '1') },
    { CODEC_ID_TSCC, MKTAG('t', 's', 'c', 'c') },
    { CODEC_ID_ULTI, MKTAG('U', 'L', 'T', 'I') },
    { CODEC_ID_VIXL, MKTAG('V', 'I', 'X', 'L') },
    { CODEC_ID_QPEG, MKTAG('Q', 'P', 'E', 'G') },
    { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '0') },
    { CODEC_ID_QPEG, MKTAG('Q', '1', '.', '1') },
    { CODEC_ID_WMV3, MKTAG('W', 'M', 'V', '3') },
    { CODEC_ID_LOCO, MKTAG('L', 'O', 'C', 'O') },
    { CODEC_ID_THEORA, MKTAG('t', 'h', 'e', 'o') },
#if LIBAVCODEC_VERSION_INT>0x000409
    { CODEC_ID_WNV1, MKTAG('W', 'N', 'V', '1') },
    { CODEC_ID_AASC, MKTAG('A', 'A', 'S', 'C') },
    { CODEC_ID_INDEO2, MKTAG('R', 'T', '2', '1') },
    { CODEC_ID_FRAPS, MKTAG('F', 'P', 'S', '1') },
    { CODEC_ID_TRUEMOTION2, MKTAG('T', 'M', '2', '0') },
#endif
#if LIBAVCODEC_VERSION_INT>((50<<16)+(1<<8)+0)
    { CODEC_ID_FLASHSV, MKTAG('F', 'S', 'V', '1') },
    { CODEC_ID_JPEGLS,MKTAG('M', 'J', 'L', 'S') }, /* JPEG-LS custom FOURCC for avi - encoder */
    { CODEC_ID_VC1, MKTAG('W', 'V', 'C', '1') },
    { CODEC_ID_VC1, MKTAG('W', 'M', 'V', 'A') },
    { CODEC_ID_CSCD, MKTAG('C', 'S', 'C', 'D') },
    { CODEC_ID_ZMBV, MKTAG('Z', 'M', 'B', 'V') },
    { CODEC_ID_KMVC, MKTAG('K', 'M', 'V', 'C') },
#endif
#if LIBAVCODEC_VERSION_INT>((51<<16)+(11<<8)+0)
    { CODEC_ID_VP5, MKTAG('V', 'P', '5', '0') },
    { CODEC_ID_VP6, MKTAG('V', 'P', '6', '0') },
    { CODEC_ID_VP6, MKTAG('V', 'P', '6', '1') },
    { CODEC_ID_VP6, MKTAG('V', 'P', '6', '2') },
    { CODEC_ID_VP6F, MKTAG('V', 'P', '6', 'F') },
    { CODEC_ID_JPEG2000, MKTAG('M', 'J', '2', 'C') },
    { CODEC_ID_VMNC, MKTAG('V', 'M', 'n', 'c') },
#endif
#if LIBAVCODEC_VERSION_INT>=((51<<16)+(49<<8)+0)
// this tag seems not to exist in older versions of FFMPEG
    { CODEC_ID_TARGA, MKTAG('t', 'g', 'a', ' ') },
#endif
    { CODEC_ID_NONE, 0 },
};
This entry was posted in OpenCV Errors. Bookmark the permalink.

10 Responses to CvVideoWriter Not Writing

  1. Vic Chen says:

    I also come across this problem and I want to store the video in YV12 format.And I see YV12 in the codec you list. But cvCreateVideoWriter still return me with NULL. I just want to ask in which header file you find all the codecs?

  2. Nathan Crock says:

    If you have the codec from the list in your program and open() is still returning NULL, then I’d say check that the codec is on your computer. If it is then it is not the codec. I would check through the open() function’s definition to see where it returns NULL. I found mine here… (where/opencv/was/installed)/modules/highgui/src/cap_XXXX.cpp where XXXX is which ever interface you’re using. Good luck.

  3. Luis Ribeiro says:

    Hi Nathan,
    I have a problem, that’s messing all my project. I’m trying to save a video capture from webcam, the video only has one channel, blue one, but I’m not able because it says it’s only possible to save a video file with 3 channels.
    heres my code:

    #include
    #include
    #include
    #include
    #include

    int main( int argc, char** argv )
    {

    CvCapture *capture; //Webcam
    IplImage *frame; //RGB
    IplImage *frame_blue; //Subtraccion Frame
    IplImage *blue; //Blue Frames
    IplImage *frame_total; //REsulting Rame = blue – frame_blue

    capture = cvCaptureFromCAM( 0 );
    if ( !capture )
    return EXIT_FAILURE;

    frame = cvQueryFrame( capture );
    if ( !frame )
    return EXIT_FAILURE;

    //cvNamedWindow( “Video” , CV_WINDOW_AUTOSIZE );
    //cvNamedWindow( “Subtractor” , CV_WINDOW_AUTOSIZE );

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

    frame_blue = cvCreateImage( cvGetSize(frame), IPL_DEPTH_8U, 1 );
    cvSplit( frame , frame_blue , 0 , 0 , 0 );
    cvShowImage(“Subtraction Frame”, frame_blue);

    blue = cvCreateImage( cvGetSize(frame), IPL_DEPTH_8U, 1 );

    frame_total = cvCreateImage( cvGetSize(frame), IPL_DEPTH_8U, 1 );

    CvVideoWriter *writer = cvCreateVideoWriter
    (
    argv[ 1 ],
    CV_FOURCC(‘D’,'I’,'V’,'X’),
    25,
    size
    );

    while( (frame = cvQueryFrame( capture )) != NULL )
    {
    frame = cvQueryFrame(capture);
    if ( !frame )
    return EXIT_FAILURE;

    cvSplit( frame , blue , 0 , 0 , 0 );

    cvSub( frame_blue, blue, frame_total, NULL );

    //- Mostrar Janelas -//
    cvShowImage(“RGB”, frame);
    cvShowImage(“Blue”, blue);
    cvShowImage(“Total”, frame_total);

    cvWriteFrame( writer, frame_total );

    char c = cvWaitKey(1);

    if (c == 27)
    return EXIT_FAILURE;
    }

    cvReleaseCapture ( &capture );
    cvReleaseVideoWriter( &writer );
    cvDestroyWindow ( “Subtraccion Frame” );
    cvDestroyWindow ( “Blue Vid” );
    cvDestroyWindow ( “Total” );

    return EXIT_SUCCESS;
    }

    please Ineed help :D

  4. Nathan Crock says:

    Hey Luis,

    I’ve never actually come across your particular problem, but yes it’s true cvVideoWriter can only write in three channels. I think I may have a fix for you. Instead of splitting the image into only the blue frame and leaving the other paramters null, split it into all three. Then if your interest is to extrapolate only the blue frames, set both the Red and Green pixel values to zero! Then use cvMerge and join all three frames again.

    There you’ll have 3-channels with only the blue values contributing to the final image.

    Good luck!

  5. TeXiCiTy says:

    Great blog.

    I am searching for a solution for my problem for days now. I have NULL output at almost every codec except IYUV and uncompressed ( insert 0 instead of CV_FOURCC ). The most disturbing fact is that all tutorials have a working FFMPEG thingie so the fourcc codes “MJPG”, “DIV3″ “PIM1″ etc all work out of the box.

    I tried using precompiled VStudio OpenCV, I also compiled it using VS and CMake, for both 2.1.0 and 2.2.0. I installed KLite codec packs, I have an standalone H264 encoder, and still every codec returns a 0-byte file. When I replace CV_FOURCC with -1 a listbox appears with codecs like “Windows RLE” and “Microsoft Video 1″ but the only options that actually produce output are “IYUV codec” and “uncompressed”. I guess the code is alright when IYUV works.

    #include
    #include

    capture = cvCaptureFromCAM( 0 );
    if ( !capture ) return 0;
    frame = cvQueryFrame( capture );
    if ( !frame ) return 0;
    CvSize size = cvSize
    ( (int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH),
    (int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT) );
    frameW = frame->width;
    frameH = frame->height;
    writer=cvCreateVideoWriter(“darn.avi”,CV_FOURCC(‘D’,'I’,'V’,’3′),fps,size,1);
    for (int j=0; j<100; j++)
    {
    frame = cvQueryFrame( capture );
    cvWriteFrame(writer, frame);
    Sleep(1000/fps);
    }
    cvReleaseVideoWriter(&writer);
    cvReleaseCapture( &capture );

    This is driving me nuts, all manuals state the following codecs should work out of the box but they don't. I am using Win7 + VStudio2008 + OpenCV2.1(atm) + cheap USB webcam.
    int fourCC_code = CV_FOURCC('P','I','M','1'); // MPEG 1 codec.
    int fourCC_code = CV_FOURCC('D','I','V','3'); // MPEG 4.3 codec.
    int fourCC_code = CV_FOURCC('I','2','6','3'); // H263I codec.
    int fourCC_code = CV_FOURCC('F','L','V','1'); // FLV1 codec.

    Do you have any idea why no encoders are working, or how I could embed the ffmpeg codec in my program?

  6. Nathan Crock says:

    Hey man,

    That does sound a bit peculiar. Well before we go any further, have you tried CV_FOURCC(‘D’,’I’,’V',’X′)?

    Cheers

  7. FLorea Stefan says:

    Hy Nathan,
    Very nice blog! Been following all your examples and tutorials.
    However, for some strange reason I am having the same problem as TeXiCiTy.

    I am using :
    python 2.7.2
    opencv 2.3


    import cv

    FPS = 25
    availableCodecs = [ cv.CV_FOURCC('i', 'Y', 'U', 'V'),
    cv.CV_FOURCC('M','J','P','G'),
    cv.CV_FOURCC('M', 'P', '4', '2'),
    cv.CV_FOURCC('D', 'I', 'V', '3'),
    cv.CV_FOURCC('D', 'I', 'V', 'X'),
    cv.CV_FOURCC('U', '2', '6', '3'),
    cv.CV_FOURCC('I', '2', '6', '3'),
    cv.CV_FOURCC('F', 'L', 'V', '1')]

    codec = -1
    isColor = 1
    nrFrames = 1200

    image = cv.LoadImage("Frames/frame_1.jpg", cv.CV_LOAD_IMAGE_COLOR)
    writer = cv.CreateVideoWriter("output_IYUV.avi", -1 , FPS, cv.GetSize(image), isColor)

    for i in range(0, nrFrames):
    fileName = "Frames/frame_" + str(i) + ".jpg"
    frame = cv.LoadImage(fileName, cv.CV_LOAD_IMAGE_COLOR)
    result = cv.WriteFrame(writer, frame)

    if result == 0:
    print "CODEC NOT GOOD"
    break

    print "writing frame:", fileName, ":", frame

    It only works for IYUV and uncompressed and it generates a very large file. just for 1minute = 700mB! I do have installed all codecs.

  8. Arpit Agarwal says:

    ^
    @FLorea Stefan : I hope you’ve figured out the solution by now, but in case you haven’t if you look at the video writer, you are not using any video codec. (-1) indicates no video codec. Hence, that could be a reason for the large size of the video file.

  9. Nathan Crock says:

    Wow, thank you for the info!

  10. Seda says:

    Great blog.I am searching for a souoitln for my problem for days now. I have NULL output at almost every codec except IYUV and uncompressed ( insert 0 instead of CV_FOURCC ). The most disturbing fact is that all tutorials have a working FFMPEG thingie so the fourcc codes MJPG , DIV3 PIM1 etc all work out of the box.I tried using precompiled VStudio OpenCV, I also compiled it using VS and CMake, for both 2.1.0 and 2.2.0. I installed KLite codec packs, I have an standalone H264 encoder, and still every codec returns a 0-byte file. When I replace CV_FOURCC with -1 a listbox appears with codecs like Windows RLE and Microsoft Video 1 but the only options that actually produce output are IYUV codec and uncompressed . I guess the code is alright when IYUV works.#include#include capture = cvCaptureFromCAM( 0 );if ( !capture ) return 0;frame = cvQueryFrame( capture );if ( !frame ) return 0;CvSize size = cvSize((int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_WIDTH),(int)cvGetCaptureProperty( capture, CV_CAP_PROP_FRAME_HEIGHT));frameW = frame->width;frameH = frame->height;writer=cvCreateVideoWriter( darn.avi ,CV_FOURCC( D’,'I’,'V’,’3 ),fps,size,1);for (int j=0; j<100; j++){frame = cvQueryFrame( capture );cvWriteFrame(writer, frame);Sleep(1000/fps);}cvReleaseVideoWriter(&writer);cvReleaseCapture( &capture );This is driving me nuts, all manuals state the following codecs should work out of the box but they don't. I am using Win7 + VStudio2008 + OpenCV2.1(atm) + cheap USB webcam.int fourCC_code = CV_FOURCC('P','I','M','1'); // MPEG 1 codec.int fourCC_code = CV_FOURCC('D','I','V','3'); // MPEG 4.3 codec.int fourCC_code = CV_FOURCC('I','2','6','3'); // H263I codec.int fourCC_code = CV_FOURCC('F','L','V','1'); // FLV1 codec.Do you have any idea why no encoders are working, or how I could embed the ffmpeg codec in my program?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>