下面的代码抛出 OSStatus 错误 1718449215,根据 Audio Queue Reference , 代表“播放数据格式不受支持。”
如果我将 AVFormatKey
更改为 kAudioFormatiLBC
或 kAudioFormatLinearPCM
,则代码可以正常工作。 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/