iOS 8中的音频录像机不处理Kaudiof或MPEG4AAC

iOS 8中的音频录像机不处理Kaudiof或MPEG4AAC,ios,objective-c,ios8,avfoundation,avaudioplayer,Ios,Objective C,Ios8,Avfoundation,Avaudioplayer,在iOS 8kaudioformampeg4aac之前,我的代码工作正常,但现在它创建了一个空文件。未报告任何错误。当我将其更改为kaudioformalinerpcm时,它可以工作。这是我的代码: recordSettings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:AVAudioQualityMin], AVEncoderAudioQualityKey, [NSNumber n

在iOS 8
kaudioformampeg4aac
之前,我的代码工作正常,但现在它创建了一个空文件。未报告任何错误。当我将其更改为
kaudioformalinerpcm
时,它可以工作。这是我的代码:

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];

请从您的设置词典中删除
avencoderbiteKey
键,它将在iOS8上使用
kAudioFormatMPEG4AAC


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

该比特率看起来低得令人怀疑,即使对于
kaudioformmpeg4aac
(每秒16字节),也可能尝试16000或64000或更多

p、 s.为您的
nsdictionary
nsarray
NSNumbers
尝试新的Objective-C文本,我认为它们是一种改进:

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

使用kAudioFormatLinearPCM,我的AVAudioRecorder无法执行录制。