Learn about the usage and requirements of “Ambient Viewing Environment” metadata with Dolby Vision™ Profile 8.4 playback.
TN3145: HDR video metadata
How to attach ambientViewingEnvironment to new pixel buffer as attachment? I tried many things but it fails.
Update: It seems the attachment needs to be copied as NSData, example
CVBufferSetAttachment(pixelBuffer, kCVImageBufferAmbientViewingEnvironmentKey, ambientViewingEnvironmentData! as NSData, .shouldPropagate)
@Jason It seems AVAssetWriter is crashing with error -12743 when appending NSData
for kCVImageBufferAmbientViewingEnvironmentKey
. Please describe how exactly to copy this attachment to new pixel buffer. Here is my code:
var ambientViewingEnvironment:CMFormatDescription.Extensions.Value?
var ambientViewingEnvironmentData:NSData?
ambientViewingEnvironment = sampleBuffer.formatDescription?.extensions[.ambientViewingEnvironment]
let plist = ambientViewingEnvironment?.propertyListRepresentation
ambientViewingEnvironmentData = plist as? NSData
And then attaching this data,
CVBufferSetAttachment(renderedPixelBuffer, kCVImageBufferAmbientViewingEnvironmentKey, ambientViewingEnvironmentData! as CFData, .shouldPropagate)