Bharat Sharma
Bharat Sharma

Reputation: 3966

How to get supported pixel format of video capture device (camera) in mac os x

Just now i start a small work related to video capture I want all supported pixel formats by a video capture device using avfoundation. I am using CMFormatDescriptionGetMediaSubtype function to get pixel format in mac(CMPixelFormatType). But i am always getting a value which is not matching from any of the available pixel format (predefined pixel fromat like: kCMPixelFormat_422YpCbCr8_yuvs). Is there any other function present for that purpose.. I searched but till now not found. Returned value is always 1684890161 as pixel format type.

Actual thing I want to ask is :

How can I have all supported pixel formats by a video capture device in Mac. Remember I am not asking for codec type. Its pixel format I need. Please help.. if possible.

Thanks in advance..

Upvotes: 1

Views: 1838

Answers (1)

Boris Prohaska
Boris Prohaska

Reputation: 912

To get all supported pixel formats, you need to call CMIOObjectGetPropertyData with the second parameter CMIOObjectPropertyAddress as follows:

CMIOObjectPropertyAddress theAddress;
theAddress.mSelector = kCMIOStreamPropertyFormatDescriptions;
theAddress.mScope    = kCMIOObjectPropertyScopeGlobal;
theAddress.mElement  = 0;

This will give you a CFArray of CMFormatDescriptionRef. Then you iterate over this array and call:

CMFormatDescriptionGetMediaSubType(yourCMFormatDescriptionRef);

Your CMFormatDescriptionGetMediaSubType translates into a FourCharacterCode (OSType) of 'dmb1' which seems to be a Matrox specific hardware compression type.

The reason, you won't find your format in the CMPixelFormatType enum is because there are only the most common formats there, which yours is not. The most common on the Mac are kCMPixelFormat_422YpCbCr8 and kCMPixelFormat_422YpCbCr10, both are raw 8 and 10 bit YUV video.

Upvotes: 2

Related Questions