问题描述
我的代码工作正常,直到iOS 8 kAudioFormatMPEG4AAC
,但现在它创建了一个空文件。没有报告错误。当我将其更改为 kAudioFormatLinearPCM
时,它可以正常工作。这是我的代码:
My code worked fine until iOS 8 kAudioFormatMPEG4AAC
but now it creates an empty file. No errors are reported. When I changed it to kAudioFormatLinearPCM
it works. This is my code:
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];
推荐答案
即使对于<$ c,该比特率看起来也很低$ c> kAudioFormatMPEG4AAC (每秒16字节),可以尝试16000或64000或更多。
That bitrate looks suspiciously low, even for kAudioFormatMPEG4AAC
(16 bytes per second), maybe try 16000 or 64000 or more.
p.s。为你的 NSDictionarys
, NSArrays
和 NSNumbers $ c尝试新的Objective-C文字$ c>,我认为它们有所改进:
p.s. try the new Objective-C literals for your NSDictionarys
, NSArrays
and NSNumbers
, I think they're an improvement:
recordSettings = @{
AVEncoderAudioQualityKey : AVAudioQualityMin,
AVFormatIDKey : @(kAudioFormatLinearPCM),
AVEncoderBitRateKey : @16000,
AVNumberOfChannelsKey : @1,
AVSampleRateKey : @32000
};
这篇关于iOS 8中的AVAudioRecorder无法处理kAudioFormatMPEG4AAC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!