Nov 26 update.
As @Deepak posted in his own answer and comments, 'x420' tagged format will let the camera work in HLG mode. All the available HLG enabled formats from IP12 Pro are updated below.
Original answer
For iOS 14.2, I can dump all the available formats from AVCaptureDevice instance, seems the log output fairly explains itself. As commented below, hopefully setting the AVCaptureDevice.activeFormat to one of the HDR+wide color format will do the job.
<AVCaptureDeviceFormat: 0x282d8daf0 'vide'/'x420' 1280x 720, { 1- 30 fps}, HRSI:4096x2304, fov:68.161, supports vis, max zoom:120.00 (upscales @2.91), AF System:2, ISO:34.0-3264.0, SS:0.000014-1.000000, supports wide color, supports depth>
<AVCaptureDeviceFormat: 0x282d8dac0 'vide'/'x420' 1280x 720, { 1- 60 fps}, HRSI:4096x2304, fov:68.161, supports vis, max zoom:120.00 (upscales @2.91), AF System:2, ISO:34.0-3264.0, SS:0.000014-1.000000, supports wide color, supports depth>
<AVCaptureDeviceFormat: 0x282d8da50 'vide'/'x420' 1920x1080, { 1- 30 fps}, HRSI:4096x2304, fov:68.161, supports vis, max zoom:120.00 (upscales @1.94), AF System:2, ISO:34.0-3264.0, SS:0.000014-1.000000, supports wide color, supports depth, supports multicam>
<AVCaptureDeviceFormat: 0x282d8da30 'vide'/'x420' 1920x1080, { 1- 60 fps}, HRSI:4096x2304, fov:68.161, supports vis, max zoom:120.00 (upscales @1.94), AF System:2, ISO:34.0-3264.0, SS:0.000014-1.000000, supports wide color, supports multicam>
<AVCaptureDeviceFormat: 0x282d8d9e0 'vide'/'x420' 1920x1440, { 1- 30 fps}, HRSI:4032x3024, fov:67.096, max zoom:189.00 (upscales @2.10), AF System:2, ISO:34.0-3264.0, SS:0.000014-1.000000, supports wide color, supports depth, supports multicam>
<AVCaptureDeviceFormat: 0x282d8d950 'vide'/'x420' 3840x2160, { 1- 30 fps}, HRSI:4096x2304, fov:68.161, supports vis, max zoom:125.25 (upscales @1.00), AF System:2, ISO:34.0-3264.0, SS:0.000014-1.000000, supports wide color, supports multicam>
As of Nov 23, it is still an ongoing investigation, I think some joint effort is needed, or some Apple engineer can have a look at this.
I believe I have watched all the available WWDC17/18/19/20 sessions on this topic, and with the new iPhone 12 release, some findings here.
Capturing HDR from camera and saved as 10 bit HLG video directly is only capable on iPhone 12 and newer. This is what it claims in the product release, and I have got sample videos from my friend's new phone, it is working as expected.
In WWDC2020, Export HDR media in your app with AVFoundation , it claims:
At this point, I’d like to briefly touch on which Apple platforms can support HDR export.
iOS supports HEVC hardware encoding on devices with Apple A10 Fusion chips or newer.
Fortunately A10 devices have been around for a while, dating back to the iPhone 7, iPads released in 2018, and the 2019 iPod touch.
In regards to Macs, both HEVC and Apple ProRes software encoders are available on all Macs.
HEVC hardware encoding is generally available on 2017 and newer Macs running the new macOS.
Hardware encoding will make the export significantly faster.
Also in this video, it claims HDR export only works 10bit HEVC encoding, so the A10+ SoC should have 10bit HEVC encoding capability. This is a guess, I can edit the iPhone12 HLG video within official Photo app on iPhone 11 and SE2, and the writing performance(4k@60p, HLG) is quite good, which is a good indicator. However, I have no luck to make this work in code, the sample code listed in the video could not be the full picture, and I am having difficulty to find a working demo yet. And in theory, older devices should have the capability to record 10bit HLG also, or the camera, thermal/power budget is the limitation here.
However, the only relevant HDR key in this is the VideoProfileLevelKey which must be set to HEVC_Main10_AutoLevel when exporting HDR using the HEVC codec.
Note that 8-bit HEVC HDR is not supported, and this key is not applicable to ProRes exports.
All right, let’s take the time now to summarize how you would configure the keys I just discussed when outputting to two common HDR formats: HLG and HDR10. This table shows what the relevant HDR settings are for exporting an HLG file.
Another video worth watching again and again: Edit and play back HDR video with AVFoundation
During the test, I do get a CVPixelBuffer(format:kCVPixelFormatType_420YpCbCr10BiPlanarFullRange) that is HDR enabled, and correctly color managed from sample HLG video. This is a dump from my console log, and it is working on any iOS 14 enabled devices, even with the quite old iPhone6s(A9), because it only involves 10bit HEVC decoding here.
_displayLinkDidRefresh():121 - Optional(<CVPixelBuffer 0x281300500 width=3840 height=2160 pixelFormat=xf20 iosurface=0x282008050 planes=2 poolName=450:decode_1>
<Plane 0 width=3840 height=2160 bytesPerRow=7680>
<Plane 1 width=1920 height=1080 bytesPerRow=7680>
<attributes={
PixelFormatDescription = {
BitsPerComponent = 10;
CGBitmapContextCompatibility = 0;
CGImageCompatibility = 0;
ComponentRange = FullRange;
ContainsAlpha = 0;
ContainsGrayscale = 0;
ContainsRGB = 0;
ContainsYCbCr = 1;
FillExtendedPixelsCallback = {length = 24, bytes = 0x0000000000000000b48ab8a1010000000000000000000000};
IOSurfaceCoreAnimationCompatibility = 1;
IOSurfaceCoreAnimationCompatibilityHTPCOK = 1;
IOSurfaceOpenGLESTextureCompatibility = 1;
OpenGLESCompatibility = 1;
PixelFormat = 2019963440;
Planes = (
{
BitsPerBlock = 16;
HorizontalSubsampling = 1;
VerticalSubsampling = 1;
},
{
BitsPerBlock = 32;
BlackBlock = {length = 4, bytes = 0x00800080};
HorizontalSubsampling = 2;
VerticalSubsampling = 2;
}
);
};
} propagatedAttachments={
CVFieldCount = 1;
CVImageBufferChromaLocationBottomField = Left;
CVImageBufferChromaLocationTopField = Left;
CVImageBufferColorPrimaries = "ITU_R_2020";
CVImageBufferTransferFunction = "ITU_R_2100_HLG";
CVImageBufferYCbCrMatrix = "ITU_R_2020";
QTMovieTime = {
TimeScale = 600;
TimeValue = 12090;
};
} nonPropagatedAttachments={
}>)