[FFmpeg-devel] [PATCH] AVFoundation: Add -pixel_format option

Thilo Borgmann thilo.borgmann at mail.de
Tue May 13 12:25:29 CEST 2014


Am 12.05.14 12:04, schrieb Thilo Borgmann:
> Am 11.05.14 19:34, schrieb Carl Eugen Hoyos:
>> sfan5 <sfan5 <at> live.de> writes:
>>
>>>>> +    { AV_PIX_FMT_BGRA, kCVPixelFormatType_32BGRA },
>>>> This should be AV_PIX_FMT_BGR0: The camera cannot
>>>> record an alpha channel, the fourth channel is (or at
>>>> least can be) 0, so it should be ignored.
>>>> Same for the other 32 bit rgb formats.
>>>
>>> Isn't AVFoundation a generic API for video sources? 
>>> (not only cameras)
>>> There might be other devices that can record RGBA.
>>
>> I can't really answer this but since AVFoundation 
>> provides transparent images for 32 bit RGB it has 
>> to be mapped to RGB0 to work at all.
>> (If a user ever protests that his alpha channel 
>> disappears, we will have to find a solution.)
>>
>>>> Right now, if I specify a pixel format that does not
>>>> work (like gray) FFmpeg prints many error messages
>>>> but does not quit. Can you reproduce this?
>>>> The expected behaviour imo is to quit if a pixel
>>>> format that does not work is requested.
>>>
>>> I can reproduce this, but I am not sure which approach 
>>> one would to take to fix this.
>>
>> I cannot really test (I only borrowed a Mac for the quick 
>> test before) but I would expect that some function call 
>> returns an error if a pixel format that is not supported 
>> is requested.
> 
> _Maybe_ the device can be queried for available/valid pixel formats.

You could try if this works:

https://developer.apple.com/library/mac/documentation/AVFoundation/Reference/AVCaptureVideoDataOutput_Class/Reference/Reference.html#//apple_ref/occ/instp/AVCaptureVideoDataOutput/availableVideoCVPixelFormatTypes

-Thilo


More information about the ffmpeg-devel mailing list