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

Brad O'Hearne brado at bighillsoftware.com
Wed Feb 6 21:20:45 CET 2013

On Feb 6, 2013, at 3:19 AM, Carl Eugen Hoyos <cehoyos at ag.or.at> wrote:

> salsaman <salsaman at ...> writes:
>> http://svn.code.sf.net/p/lives/code/trunk/src/colourspace.c
>> (search for convert_yuyv_to_yuv420_frame).
> This does not look like a good idea, I would 
> expect libswscale to be a magnitude faster.
> (and it supports other pix_fmts as well.)

Carl, Salsaman, Alex, Michel (I hope I listed everyone, if I missed someone -- apologies, you too are included), I want to give you guys a huge thanks for the guidance and thoughts on this. I now have video successfully being captured from a webcam, being encoded into FLV format, and published to a Wowza server where it is being consumed by a Flash player. I still have to stream the audio, so there's a good chance you'll be getting some more questions from me on this, but at this point, this is a major leap toward the end result. So here was the answer: 

My app is pinned back to Snow Leopard for compatibility, so that unfortunately limited me to pixel formats supported by the QTKit API version compatible with OS X 10.6.x, reducing my options there. But I was able to connected the wires: the QTCaptureDecompressedVideoOutput pixel format of kCVPixelFormatType_422YpCbCr8 coincides with the FFmpeg AV_PIX_FMT_UYVY422 pixel format. So I filled an input AVFrame, converted it to a new frame in AV_PIX_FMT_YUV420P pixel format using sws_scale, and then FLV encoding and RTMP streaming worked as expected.  

So therein was the answer, and knowing that this use case is not all that uncommon (and having spent huge amounts of time Google-touring corners of the Internet for an answer), I hope that others can benefit knowing that a) it can be done, and b) here's how. I'd love to be able to provide some code (in a little more general format) out on Github in the near future. 

Again guys, thanks...and I'm sure I'll be back soon for audio questions...



More information about the Libav-user mailing list