AVAudioRecorder - 为什么为 8000 AVSampleRateKey 应用 32000 AVEncoderBitRateKey 会导致 AudioCodecInitialize 失败?

问题描述 投票:0回答:1

目前,我想设置一个合理质量的录音,这会消耗最小的磁盘空间。

我尝试使用以下设置

  1. AVSampleRateKey:8000 - “电话和加密对讲机、无线对讲机和无线麦克风传输;足以用于人类语音,但没有嘶嘶声(ess 听起来像 eff (/s/, /f/))。”来自 https://en.wikipedia.org/wiki/Sampling_(signal_processing)
  2. AVEncoderBitRateKey:32000 - “32 kbit/s – 通常仅适用于语音”。来自 https://en.wikipedia.org/wiki/Bit_rate

如果我使用以下设置

AVAudioRecorder

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

avAudioRecorder.record()

期间会导致
AudioCodecInitialize failed

错误

我当前的解决方法是消除

AVEncoderBitRateKey
,并应用以下设置。

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

但是,我还是想知道,为什么32000

AVEncoderBitRateKey
会失败,有什么办法可以进一步优化,以达到合理的质量和最小的磁盘空间,用于录音?

ios swift audio-recording
1个回答
0
投票

是320,000而不是32,000。请在您的共享论文中检查 kbit。

© www.soinside.com 2019 - 2024. All rights reserved.