IOS录制音频 我用的是AVAudioRecorder这个控件,默认录制为caf格式文件,可用第三方lame转成mp3格式文件
使用前先引用框架 <AVFoundation/AVFoundation.h>
1.录音用的控件是AVAudioRecorder,录音的主要代码:
recordedFile=[NSURL URLWithString:[NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat: @"%@.%@", @"aaa",@"caf"]]];//录音文件的位置
recorder = [[AVAudioRecorder alloc] initWithURL:recordedFile settings:recordSetting error:nil];
[recorder setDelegate:self];
[recorder prepareToRecord];
[recorder record];
2.录音完成后,引用了lame之后,转化的过程核心代码:
NSString *cafFilePath =[NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@",@"aaa",@"caf"]] ;//原caf文件位置
NSString *mp3FilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:[

本文介绍了在iOS中如何使用AVAudioRecorder录制caf格式音频,并通过lame库将其转换为mp3。讨论了在转换过程中遇到的问题,如lame版本、AVFoundation框架的引用、文件路径处理以及AVAudioPlayer的播放设置等。

2454

被折叠的 条评论
为什么被折叠?



