ios – AVAudioRecorder – Why applying 32000 AVEncoderBitRateKey for a 8000 AVSampleRateKey will cause AudioCodecInitialize failed?


Presently, I want to setup an inexpensive prime quality sound recording, which consumes minimal disk home.

I try to make use of the following setup

  1. AVSampleRateKey: 8000 – “Cellphone and encrypted walkie-talkie, wi-fi intercom and wi-fi microphone transmission; passable for human speech nonetheless with out sibilance (ess seems like eff (/s/, /f/)).” From https://en.wikipedia.org/wiki/Sampling_(signal_processing)
  2. AVEncoderBitRateKey: 32000 – “32 kbit/s – usually acceptable only for speech”. From https://en.wikipedia.org/wiki/Bit_rate

If I benefit from the following settings for AVAudioRecorder

let settings = [
    AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
    AVNumberOfChannelsKey: 1,
    AVSampleRateKey: 8000,
    AVEncoderBitRateKey: 32000,
    AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
]

It could set off AudioCodecInitialize failed error all through avAudioRecorder.file()

My current workaround is to do away with AVEncoderBitRateKey, and apply the following settings.

let settings = [
    AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
    AVNumberOfChannelsKey: 1,
    AVSampleRateKey: 8000,
    AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
]

However, I nonetheless wish to know, why 32000 AVEncoderBitRateKey will fail, and is there any method I can extra optimize, to realize low-cost prime quality and minimal disk home, for sound recording?



Supply hyperlink

Leave a Reply

Your email address will not be published.