I am getting CMSampleBuffers in kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange
format from the camera. The pixel buffers are 10 bit HDR. I need to record using ProRes422 codec but in non-HDR format. I am not sure what is a reliable way of doing this so reaching out here. What I did is simply set AVAssetWriter compression dictionary as follows:
compressionSettings[AVVideoTransferFunctionKey] = AVVideoTransferFunction_ITU_R_709_2
compressionSettings[AVVideoColorPrimariesKey] = AVVideoColorPrimaries_ITU_R_709_2
compressionSettings[AVVideoYCbCrMatrixKey] = AVVideoYCbCrMatrix_ITU_R_709_2
It works and the end video recording shows the color space to be HD 1-1-1 with Apple ProRes codec. But I am not sure if AVAssetWriter has actually performed colorspace conversion from HDR 10 to BT.709, or simply clipped the colors out of range.
I need to know a definitive way to achieve this. I see Apple's native camera app is doing this, but not sure how.