AVAssetWriter audio settings failure with compression settings

I have the following audio compression settings which fail with AVAssetWriter (mov container, HEVC codec, kAudioFormatMPEG4AAC format ID):

["AVSampleRateKey": 48000,  "AVFormatIDKey": 1633772320, "AVNumberOfChannelsKey": 1, "AVEncoderBitRatePerChannelKey": 128000, "AVChannelLayoutKey": <02006500 00000000 00000000 00000000 00000000 00000000 00000000 00000000>]

Here is the code line that fails:


if _assetWriter?.canApply(outputSettings: audioSettings!, forMediaType: AVMediaType.audio) ?? false {

 } else {
     /* Failure */
 }

Want to understand what is wrong? I can not reproduce it at my end (only reproducible on user's device with a particular microphone).

I need to know if it is mandatory to provide value for AVChannelLayoutKey in the dictionary with kAudioFormatMPEG4AAC? That could be a possible culprit.

This again turns out to be another bug in iOS 16.0 where sample buffers received via AVCaptureAudioDataOutput continue to have stale/incorrect formatDescription when external mic is inserted.

AVAssetWriter audio settings failure with compression settings
 
 
Q