如何在iOS中使用AvAudiorecorder将音频录制为mp3文件

问题描述 投票:0回答:2

如何使用AvAudiorecorder将音频录制为mp3文件? 我使用以下代码进行录音机设置

recordSetting =  [NSDictionary dictionaryWithObjectsAndKeys:
                  [NSNumber numberWithInt:AVAudioQualityMin],AVEncoderAudioQualityKey,
                  [NSNumber numberWithInt:16], 
                   AVEncoderBitRateKey,
                   [NSNumber numberWithInt: 2], 
                   AVNumberOfChannelsKey,
                   [NSNumber numberWithFloat:44100.0], 
                   AVSampleRateKey, nil];
iphone record avaudiorecorder
2个回答
12
投票

添加

[NSNumber numberWithInt:kAudioFormatMPEGLayer3] forKey:AVFormatIDKey

但是由于版权问题,在 iPhone 上无法编码 mp3 格式。


6
投票

虽然您可以使用

AVAudioPlayer
播放 MP3 文件,但无法使用
AVAudioRecorder
以 MP3 格式录制(请参阅 this SO postthis SO post)。如果您需要压缩格式,但不一定是 MP3,我建议以 AAC 格式录制。

© www.soinside.com 2019 - 2024. All rights reserved.