使用AVAudioRecorder的caf音频文件的推荐编码是什么

时间:2016-03-18 01:40:39

标签: ios objective-c audio

如果我想录制到iOS上的“caf”音频文件,推荐的音频编码是什么?我认为kAudioFormatMPEGLayer2是正确的,但我似乎无法使用谷歌找到明确的答案。如果这有用的话,这是我的代码。

NSString *audioFilePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:path];
_audioFileURL = [NSURL fileURLWithPath:audioFilePath];
_audioQuality = [NSNumber numberWithInt:AVAudioQualityHigh];
_audioEncoding = [NSNumber numberWithInt:kAudioFormatMPEGLayer2];
_audioChannels = [NSNumber numberWithInt:2];
_audioSampleRate = [NSNumber numberWithFloat:44100.0];

NSDictionary *recordSettings = [NSDictionary dictionaryWithObjectsAndKeys:
        _audioQuality, AVEncoderAudioQualityKey,
        _audioEncoding, AVFormatIDKey,
        _audioChannels, AVNumberOfChannelsKey,
        _audioSampleRate, AVSampleRateKey,
        nil];

NSError *error = nil;

_audioRecorder = [[AVAudioRecorder alloc]
              initWithURL:_audioFileURL
              settings:recordSettings
              error:&error];

_audioRecorder.delegate = self;

0 个答案:

没有答案