objective-c - iOS 上的 AVAudioRecorder 错误 "playback data format is unsupported"?

标签 objective-c ios cocoa-touch ios4

下面的代码抛出 OSStatus 错误 1718449215,根据 Audio Queue Reference , 代表“播放数据格式不受支持。”

如果我将 AVFormatKey 更改为 kAudioFormatiLBCkAudioFormatLinearPCM,则代码可以正常工作。 iOS 是否支持使用 kAudioFormatMPEG4AAC_HE 进行录制?

NSDictionary *settings = 
   [NSDictionary dictionaryWithObjectsAndKeys:
   [NSNumber numberWithFloat: 32000.0],                AVSampleRateKey,
   [NSNumber numberWithInt: kAudioFormatMPEG4AAC_HE],  AVFormatIDKey,
   [NSNumber numberWithInt: 1],                        AVNumberOfChannelsKey,
   [NSNumber numberWithInt: AVAudioQualityMedium],     AVEncoderAudioQualityKey,
nil];

NSError *error = nil;
AVAudioRecorder *avRecorder = [[AVAudioRecorder alloc] 
                                initWithURL:url 
                                settings:settings 
                                error:&error];

NSAssert(error.code != 1718449215,  @"The playback data format is unsupported.");

最佳答案

Apple 文档,特别是多媒体编程指南 ( http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/MultimediaPG/UsingAudio/UsingAudio.html ),仅将 HE-AAC 列为播放格式。常规 AAC 列出用于播放和录制。因此,看来 HE-AAC 仅得到部分支持。

关于objective-c - iOS 上的 AVAudioRecorder 错误 "playback data format is unsupported"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7086452/

相关文章:

ios - 无法从源工具包生成 Swift 表示错误无法加载模块 : GoogleSignin

ios - 在检测到隐私设置更改时让应用程序自行重启

iphone - 为什么 Cocoa-Touch 类 ivars 具有前导下划线字符?

objective-c - 从 NSMutableString 中删除最后一个字符

iOS - map View 的自定义图形

objective-c - 避免重新初始化我的 TableView 数据源(核心数据)

iphone - 如何在 iPhone 应用程序中实现半圆形按钮

iphone - 在 UIScrollView 中缩放 UIImageView 越界

ios - Swift 字典的 Swift 数组

ios - 如果滚动 UITableView 时出现 popViewController,应用程序崩溃