Impossible to control AAC parameters with AVAudioFile writer

Hello all,

I'm trying to write an AAC-compressed audio file in M4A or CAF file format with AVAudioFile.
I'm using the following settings dictionary:
Code Block swift
settings = [AVFormatIDKey: kAudioFormatMPEG4AAC,
AVSampleRateKey: 48000.0,
AVNumberOfChannelsKey: 2,
AVEncoderBitRateStrategyKey: AVAudioBitRateStrategy_Variable,
AVEncoderBitRatePerChannelKey: 64,
AVEncoderAudioQualityForVBRKey: AVAudioQuality.high,
AVEncoderBitDepthHintKey: 16] as [String : Any]

Output file is OK, but my issues are
  • changing the bit rate strategy, the bit rate value or the encoder audio quality has no impact whatsoever on the output file,

  • switching from CAF to M4A file format with the same settings make a big change in the file size but it should not.

My question is simple:
Is there an issue with my settings dictionary or is it a known issue with AVAudioFile?
I spent quite some time exploring how to build this dictionary on the web and the Apple documentation (very limited on this topic I must say), but I can't find what I do wrong...

More details about this issue are available here :
https://gitlab.com/AudioScientist/avaudiofileaacparameters

Thank you for your help :)
Anybody ? 😕
Impossible to control AAC parameters with AVAudioFile writer
 
 
Q