How to look up Photo Pixel Formate Types?

I listed the AVCapturePhotoSettings.availablePhotoPixelFormatTypes array in my iPhone 14 during a running photo session and I got these type numbers:

875704422
875704438
1111970369

I have no idea what these numbers mean. How can I use these numbers to look up a human readable string that can tell me what these types are in a way I am familiar with, such as jpeg, tiff, png, bmp, dng, etc, so I know which of these numbers to choose when I instantiate the class: AVCaptureSession?

Answered by DTS Engineer in 758648022

Hello,

These values are the integer representation of the Four Character Code (FourCC) that represents the pixel format.

If you run the following:

let pixelFormats: [UInt32] = [875704422, 875704438, 1111970369]
            
for format in pixelFormats {
    let formatDescription = try! CMVideoFormatDescription(videoCodecType: .init(rawValue: format), width: 0, height: 0)
                
    print(formatDescription.mediaSubType.description)
}

You will see that these values correspond to the '420f', '420v', and 'BGRA' pixel formats respectively.

From there, you can determine the "kCVPixelFormatType" constant matches the FourCC by looking at the CoreVideo pixel format type constants within CVPixelBuffer.h

In this case, that is kCVPixelFormatType_420YpCbCr8BiPlanarFullRange, kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange, and kCVPixelFormatType_32BGRA respectively.

Accepted Answer

Hello,

These values are the integer representation of the Four Character Code (FourCC) that represents the pixel format.

If you run the following:

let pixelFormats: [UInt32] = [875704422, 875704438, 1111970369]
            
for format in pixelFormats {
    let formatDescription = try! CMVideoFormatDescription(videoCodecType: .init(rawValue: format), width: 0, height: 0)
                
    print(formatDescription.mediaSubType.description)
}

You will see that these values correspond to the '420f', '420v', and 'BGRA' pixel formats respectively.

From there, you can determine the "kCVPixelFormatType" constant matches the FourCC by looking at the CoreVideo pixel format type constants within CVPixelBuffer.h

In this case, that is kCVPixelFormatType_420YpCbCr8BiPlanarFullRange, kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange, and kCVPixelFormatType_32BGRA respectively.

How to look up Photo Pixel Formate Types?
 
 
Q