'AVAudioRecorder - Why applying 32000 AVEncoderBitRateKey for a 8000 AVSampleRateKey will cause AudioCodecInitialize failed?
Currently, I want to setup a reasonable quality sound recording, which consumes minimal disk space.
I try to use the following setup
- AVSampleRateKey: 8000 - "Telephone and encrypted walkie-talkie, wireless intercom and wireless microphone transmission; adequate for human speech but without sibilance (ess sounds like eff (/s/, /f/))." From https://en.wikipedia.org/wiki/Sampling_(signal_processing)
- AVEncoderBitRateKey: 32000 - "32 kbit/s – generally acceptable only for speech". From https://en.wikipedia.org/wiki/Bit_rate
If I use the following settings for AVAudioRecorder
let settings = [
AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
AVNumberOfChannelsKey: 1,
AVSampleRateKey: 8000,
AVEncoderBitRateKey: 32000,
AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
]
It will cause AudioCodecInitialize failed error during avAudioRecorder.record()
My current workaround is to eliminate AVEncoderBitRateKey, and apply the following settings.
let settings = [
AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
AVNumberOfChannelsKey: 1,
AVSampleRateKey: 8000,
AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
]
However, I still would like to know, why 32000 AVEncoderBitRateKey will fail, and is there any way I can further optimize, to achieve reasonable quality and minimal disk space, for sound recording?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
