AVAssetWriter error -12743 appending HDR Metadata

43 Views Asked by At

It seems AVAssetWriter is rejecting CVPixelBuffers with error -12743 when appending NSData for kCVImageBufferAmbientViewingEnvironmentKey for HDR videos. 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(dstPixelBuffer, kCVImageBufferAmbientViewingEnvironmentKey,
 ambientViewingEnvironmentData! as CFData, .shouldPropagate)

No matter what I do, including copying the attachment from sourcePixelBuffer to destinationPixelBuffer as it is, the error remains!

  var attachmentMode:CVAttachmentMode = .shouldPropagate
  let attachment = CVBufferCopyAttachment(sourcePixelBuffer!, kCVImageBufferAmbientViewingEnvironmentKey, &attachmentMode)
  NSLog("Attachment \(attachment!), mode \(attachmentMode)")
  CVBufferSetAttachment(dstPixelBuffer, kCVImageBufferAmbientViewingEnvironmentKey, attachment!, attachmentMode)

I need to know if there is anything wrong in the way metadata is copied.

0

There are 0 best solutions below