[Libav-user] Mapping / converting QTCapture's to FFmpeg's pixel format

Brad O'Hearne brado at bighillsoftware.com
Tue Feb 5 01:31:41 CET 2013


Thanks for the reply. I've tried both PIX_FMT_NV12 and PIX_FMT_NV21 (in fact, those were the ones I originally thought would work based on description). However, when I use either of those formats in place of  PIX_FMT_YUV420P in the following line of code: 

int returnVal = avpicture_fill((AVPicture*)avFrame, frameBufferBaseAddress, PIX_FMT_YUV420P, width, height);

then while it executes the avpicture_fill line successfully, the subsequent line of code 

returnVal = avcodec_encode_video2(_videoStream->codec, &avPacket, avFrame, &gotPacket);

crashes the whole app with an EXC_BAD_ACCESS error --  and there's no message of any kind written to the console. I have no idea what is causing the crash. Here's the complete block of the code between those two lines: 

 int returnVal = avpicture_fill((AVPicture*)avFrame, frameBufferBaseAddress, PIX_FMT_NV21, width, height);
    if (returnVal < 0)
        if (error)
        	NSLOG(@"Frame fill failed.");
        return NO;

    AVPacket avPacket;
    avPacket.data = NULL;
    avPacket.size = 0;
    int gotPacket;
    returnVal = avcodec_encode_video2(_videoStream->codec, &avPacket, avFrame, &gotPacket);

That's been pretty standard for most of the other pixel formats I've tried. There have been one or two that didn't crash the app, but had very wacky distortions (like half the image being neon green), but most of them just crash the app outright. 



On Feb 4, 2013, at 4:55 PM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:

> Brad O'Hearne <brado at ...> writes:
>> "Bi-Planar Component Y'CbCr 8-bit 4:2:0, full-range 
>> (luma=[0,255] chroma=[1,255]). baseAddr points to a 
>> big-endian CVPlanarPixelBufferInfo_YCbCrBiPlanar struct."
>> My code (heavily abridged for brevity) hits these high points: 
>> NOTE: frameBufferAddress is a CVImageBufferRef received 
>> from the QT capture callback: 
>>     int returnVal = avpicture_fill((AVPicture*)avFrame, 
>> frameBufferBaseAddress, PIX_FMT_YUV420P, width, height);
> Could "biplanar" point to AV_PIX_FMT_NV12?
> (Or something else that is not AV_PIX_FMT_YUV420P)
> Carl Eugen
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20130204/2c1a939a/attachment.html>

More information about the Libav-user mailing list