<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks for the reply Michel. I've actually tried the following pixel formats on the QT Capture side: <div><br></div><div><dt style="clear: both; margin-top: 0em; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><code class="jump constantName" style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); ">kCVPixelFormatType_420YpCbCr8Planar</code></dt><dd style="margin-left: 1.25em; margin-top: 0.083em; margin-bottom: 0.5em; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); position: static; z-index: auto; "><div style="margin-top: -0.083em; margin-bottom: 0.5em; ">Planar Component Y'CbCr 8-bit 4:2:0. <code style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); ">baseAddr</code> points to a big-endian <code style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); ">CVPlanarPixelBufferInfo_YCbCrPlanar</code> struct.</div></dd><a name="//apple_ref/c/econst/kCVPixelFormatType_420YpCbCr8PlanarFullRange" title="kCVPixelFormatType_420YpCbCr8PlanarFullRange" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/c_ref/kCVPixelFormatType_420YpCbCr8PlanarFullRange" title="kCVPixelFormatType_420YpCbCr8PlanarFullRange" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/uid/TP40010034-CH3-SW60" title="kCVPixelFormatType_420YpCbCr8PlanarFullRange" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/uid/TP40010034-CH3-DontLinkElementID_67" href="file:///Users/brado/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleOSX10_8.CoreReference.docset/Contents/Resources/Documents/documentation/QuartzCore/Reference/CVPixelFormatDescriptionRef/Reference/reference.html" style="color: rgb(0, 51, 102); text-decoration: none; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><dt style="clear: both; margin-top: 0em; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><code class="jump constantName" style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); ">kCVPixelFormatType_420YpCbCr8PlanarFullRange</code></dt><dd style="margin-left: 1.25em; margin-top: 0.083em; margin-bottom: 0.5em; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); position: static; z-index: auto; "><div style="margin-top: -0.083em; margin-bottom: 0.5em; ">Planar Component Y'CbCr 8-bit 4:2:0, full range. <code style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); ">baseAddr</code> points to a big-endian <code style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); ">CVPlanarPixelBufferInfo_YCbCrPlanar</code> struct.</div></dd><a name="//apple_ref/c/econst/kCVPixelFormatType_422YpCbCr_4A_8BiPlanar" title="kCVPixelFormatType_422YpCbCr_4A_8BiPlanar" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/c_ref/kCVPixelFormatType_422YpCbCr_4A_8BiPlanar" title="kCVPixelFormatType_422YpCbCr_4A_8BiPlanar" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/uid/TP40010034-CH3-SW61" title="kCVPixelFormatType_422YpCbCr_4A_8BiPlanar" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/uid/TP40010034-CH3-DontLinkElementID_68" href="file:///Users/brado/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleOSX10_8.CoreReference.docset/Contents/Resources/Documents/documentation/QuartzCore/Reference/CVPixelFormatDescriptionRef/Reference/reference.html" style="color: rgb(0, 51, 102); text-decoration: none; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/c/econst/kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange" title="kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/c_ref/kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange" title="kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/uid/TP40010034-CH3-SW62" title="kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/uid/TP40010034-CH3-DontLinkElementID_69" href="file:///Users/brado/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleOSX10_8.CoreReference.docset/Contents/Resources/Documents/documentation/QuartzCore/Reference/CVPixelFormatDescriptionRef/Reference/reference.html" style="color: rgb(0, 51, 102); text-decoration: none; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><dt style="clear: both; margin-top: 0em; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><code class="jump constantName" style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); ">kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange</code></dt><dd style="margin-left: 1.25em; margin-top: 0.083em; margin-bottom: 0.5em; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); position: static; z-index: auto; "><div style="margin-top: -0.083em; margin-bottom: 0.5em; ">Bi-Planar Component Y'CbCr 8-bit 4:2:0, video-range (luma=[16,235] chroma=[16,240]). <code style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); ">baseAddr</code> points to a big-endian <code style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); ">CVPlanarPixelBufferInfo_YCbCrBiPlanar</code> struct.</div></dd><a name="//apple_ref/c/econst/kCVPixelFormatType_420YpCbCr8BiPlanarFullRange" title="kCVPixelFormatType_420YpCbCr8BiPlanarFullRange" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/c_ref/kCVPixelFormatType_420YpCbCr8BiPlanarFullRange" title="kCVPixelFormatType_420YpCbCr8BiPlanarFullRange" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/uid/TP40010034-CH3-SW63" title="kCVPixelFormatType_420YpCbCr8BiPlanarFullRange" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/uid/TP40010034-CH3-DontLinkElementID_70" href="file:///Users/brado/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleOSX10_8.CoreReference.docset/Contents/Resources/Documents/documentation/QuartzCore/Reference/CVPixelFormatDescriptionRef/Reference/reference.html" style="color: rgb(0, 51, 102); text-decoration: none; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><dt style="clear: both; margin-top: 0em; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "><code class="jump constantName" style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); ">kCVPixelFormatType_420YpCbCr8BiPlanarFullRange</code></dt><dd style="margin-left: 1.25em; margin-top: 0.083em; margin-bottom: 0.5em; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); position: static; z-index: auto; "><div style="margin-top: -0.083em; margin-bottom: 0.5em; ">Bi-Planar Component Y'CbCr 8-bit 4:2:0, full-range (luma=[0,255] chroma=[1,255]). <code style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); ">baseAddr</code> points to a big-endian <code style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); ">CVPlanarPixelBufferInfo_YCbCrBiPlanar</code> struct.</div></dd><a name="//apple_ref/c/econst/kCVPixelFormatType_422YpCbCr8_yuvs" title="kCVPixelFormatType_422YpCbCr8_yuvs" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/c_ref/kCVPixelFormatType_422YpCbCr8_yuvs" title="kCVPixelFormatType_422YpCbCr8_yuvs" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/uid/TP40010034-CH3-SW64" title="kCVPixelFormatType_422YpCbCr8_yuvs" style="color: rgb(51, 102, 204); font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><a name="//apple_ref/doc/uid/TP40010034-CH3-DontLinkElementID_71" href="file:///Users/brado/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleOSX10_8.CoreReference.docset/Contents/Resources/Documents/documentation/QuartzCore/Reference/CVPixelFormatDescriptionRef/Reference/reference.html" style="color: rgb(0, 51, 102); text-decoration: none; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); "></a><div><br></div><div>The first two cause the <span style="color: rgb(61, 29, 129); font-family: Menlo; font-size: 11px; ">avcodec_encode_video2 </span>line to crash. The last two transmit video properly but are distorted. I have in my mind that the first one is probably the right pixel format (also the one I need to use), but there's some state of the resulting frame / packet that isn't being set properly I'm guessing, and it is causing to dereference a null pointer somewhere inside libavcodec. Does anyone have any idea what might be causing this? Is there some value I need to set before encoding the video? </div><div><br></div><div>Thanks,</div><div><br></div><div>Brad</div><div><br><div><div>On Feb 4, 2013, at 6:05 PM, Michel Marchand <<a href="mailto:michel@marex.tv">michel@marex.tv</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I'm no expert in ffmpeg but one in broadcast video and normally YCrCb 422 is not full range that is Y ranges from16 to 235 and Cr/Cb are signed and range from 16 to 240 (128 being 0). The Full range term may use the full 0-255 range and that could cause problems but not sure...<br>
<br><div class="gmail_quote">On Mon, Feb 4, 2013 at 7:31 PM, Brad O'Hearne <span dir="ltr"><<a href="mailto:brado@bighillsoftware.com" target="_blank">brado@bighillsoftware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Carl, <div><br></div><div>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 <span style="color:rgb(61,29,129);font-family:Menlo;font-size:11px">PIX_FMT_YUV420P </span>in the following line of code: </div>
<div class="im"><div><br></div><div><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">int</span><span style="font-family:Menlo;font-size:11px"> returnVal = </span><span style="font-family:Menlo;font-size:11px;color:rgb(61,29,129)">avpicture_fill</span><span style="font-family:Menlo;font-size:11px">((</span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)">AVPicture</span><span style="font-family:Menlo;font-size:11px">*)avFrame, frameBufferBaseAddress, </span><span style="font-family:Menlo;font-size:11px;color:rgb(61,29,129)">PIX_FMT_YUV420P</span><span style="font-family:Menlo;font-size:11px">, width, height);</span></div>
<div><font face="Menlo"><span style="font-size:11px"><br></span></font></div></div><div>then while it executes the avpicture_fill line successfully, the subsequent line of code </div><div class="im"><div><br></div><div><span style="font-family:Menlo;font-size:11px">returnVal = </span><span style="font-family:Menlo;font-size:11px;color:rgb(61,29,129)">avcodec_encode_video2</span><span style="font-family:Menlo;font-size:11px">(</span><span style="font-family:Menlo;font-size:11px;color:rgb(79,129,135)">_videoStream</span><span style="font-family:Menlo;font-size:11px">-></span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)">codec</span><span style="font-family:Menlo;font-size:11px">, &avPacket, avFrame, &gotPacket);</span></div>
<div><br></div></div><div>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: </div>
<div><br></div><div><div style="margin:0px;font-size:11px;font-family:Menlo">... </div><div style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:#bb2ca2">int</span> returnVal = <span style="color:#3d1d81">avpicture_fill</span>((<span style="color:#703daa">AVPicture</span>*)avFrame, frameBufferBaseAddress, <span style="color:#3d1d81">PIX_FMT_NV21</span>, width, height);</div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "> <br></div><div style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:#bb2ca2">if</span> (returnVal < <span style="color:#272ad8">0</span>)</div>
<div style="margin:0px;font-size:11px;font-family:Menlo"> {</div><div style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:#bb2ca2">if</span> (error)</div><div style="margin:0px;font-size:11px;font-family:Menlo">
{</div><div style="margin:0px;font-size:11px;font-family:Menlo"><div style="margin:0px;color:rgb(209,47,27)"><span style=""> <span style="white-space:pre-wrap"> </span></span><span style="color:#31595d">NSLOG</span><span style="">(</span>@"Frame fill failed."<span style="">);</span></div>
</div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="color:rgb(209,47,27)"> </span><span style="color:rgb(209,47,27)">}</span></div><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; ">
<br></div><div style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:#bb2ca2">return</span> <span style="color:#bb2ca2">NO</span>;</div><div style="margin:0px;font-size:11px;font-family:Menlo">
}</div><div style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(0,132,0)"> <span style="color:rgb(112,61,170)">AVPacket</span> avPacket;</div>
<div style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:#3d1d81">av_init_packet</span>(&avPacket);</div><div style="margin:0px;font-size:11px;font-family:Menlo"> avPacket.<span style="color:#703daa">data</span> = <span style="color:#bb2ca2">NULL</span>;</div>
<div style="margin:0px;font-size:11px;font-family:Menlo"> avPacket.<span style="color:#703daa">size</span> = <span style="color:#272ad8">0</span>;</div><div style="margin:0px;font-size:11px;font-family:Menlo"> <span style="color:#bb2ca2">int</span> gotPacket;</div>
<div class="im"><div style="margin: 0px; font-size: 11px; font-family: Menlo; min-height: 13px; "> <br></div><div style="margin:0px;font-size:11px;font-family:Menlo"> returnVal = <span style="color:#3d1d81">avcodec_encode_video2</span>(<span style="color:#4f8187">_videoStream</span>-><span style="color:#703daa">codec</span>, &avPacket, avFrame, &gotPacket);</div>
<div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(0,132,0)">...</div></div></div><div><br></div><div>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. </div>
<div><br></div><div>Ideas? </div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Brad</div></font></span><div><div class="h5"><div><br></div><div><div><div>On Feb 4, 2013, at 4:55 PM, Carl Eugen Hoyos <<a href="mailto:cehoyos@ag.or.at" target="_blank">cehoyos@ag.or.at</a>> wrote:</div>
<br><blockquote type="cite">Brad O'Hearne <brado@...> writes:<br><br><blockquote type="cite">"Bi-Planar Component Y'CbCr 8-bit 4:2:0, full-range <br>(luma=[0,255] chroma=[1,255]). baseAddr points to a <br>
big-endian CVPlanarPixelBufferInfo_YCbCrBiPlanar struct."<br><br>My code (heavily abridged for brevity) hits these high points: <br><br>NOTE: frameBufferAddress is a CVImageBufferRef received <br>from the QT capture callback: <br>
<br> int returnVal = avpicture_fill((AVPicture*)avFrame, <br>frameBufferBaseAddress, PIX_FMT_YUV420P, width, height);<br></blockquote><br>Could "biplanar" point to AV_PIX_FMT_NV12?<br>(Or something else that is not AV_PIX_FMT_YUV420P)<br>
<br>Carl Eugen<br><br>_______________________________________________<br>Libav-user mailing list<br><a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br><a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</blockquote></div><br></div></div></div></div><br>_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br></blockquote></div><br>
_______________________________________________<br>Libav-user mailing list<br><a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>http://ffmpeg.org/mailman/listinfo/libav-user<br></blockquote></div><br></div></div></body></html>