【问题标题】:AVAudioRecorder in iOS 8 does not handle kAudioFormatMPEG4AACiOS 8 中的 AVAudioRecorder 不处理 kAudioFormatMPEG4AAC
【发布时间】:2014-11-27 21:03:39
【问题描述】:

我的代码在 iOS 8 kAudioFormatMPEG4AAC 之前运行良好,但现在它创建了一个空文件。没有错误报告。当我将其更改为 kAudioFormatLinearPCM 时,它可以工作。这是我的代码:

recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:
    [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey,
    [NSNumber numberWithInt: kAudioFormatLinearPCM], AVFormatIDKey,
    [NSNumber numberWithInt:16], AVEncoderBitRateKey,
    [NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
    [NSNumber numberWithFloat:32000.0], AVSampleRateKey,
    nil];

【问题讨论】:

    标签: ios objective-c ios8 avfoundation avaudioplayer


    【解决方案1】:

    请从您的设置字典中删除 AVEncoderBitRateKey 键,它将在带有 kAudioFormatMPEG4AAC 的 iOS8 上运行。

    这可能是AVEncoderBitRateKeyAVNumberOfChannelsKey 之间的特定关联。但我没有使用参数,而是使用默认比特率值来获得工作记录器。

    【讨论】:

      【解决方案2】:

      即使kAudioFormatMPEG4AAC(每秒 16 字节),比特率看起来低得令人怀疑,也许尝试 16000 或 64000 或更高。

      附言为您的 NSDictionarysNSArraysNSNumbers 尝试新的 Objective-C 文字,我认为它们是一种改进:

      recordSettings = @{
          AVEncoderAudioQualityKey : AVAudioQualityMin,
          AVFormatIDKey : @(kAudioFormatLinearPCM),
          AVEncoderBitRateKey : @16000,
          AVNumberOfChannelsKey : @1,
          AVSampleRateKey : @32000
      }; 
      

      【讨论】:

      • 使用 kAudioFormatLinearPCM,我的 AVAudioRecorder 无法进行录音。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多