如何以 .mp3 格式录制音频文件? [英] How to record an audio file in .mp3 format?

查看:42
本文介绍了如何以 .mp3 格式录制音频文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下设置使用 AVAudioRecorder 录制 .mp3 格式的音频文件.

I am using the following settings for recording audio file in .mp3 format using AVAudioRecorder.

NSDictionary *recordSettings = [[NSDictionary alloc] initWithObjectsAndKeys:

                                        [NSNumber numberWithFloat: 44100.0],AVSampleRateKey,
                                        [NSNumber numberWithInt: kAudioFormatMPEGLayer3],AVFormatIDKey,
                                        [NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
                                        [NSNumber numberWithInt: AVAudioQualityMax],AVEncoderAudioQualityKey,nil];

但是不能用这些来记录.我为此搜索了很多,但无法获得一些相关的帖子.有些帖子说这是不可能的.如果不可能,那为什么会这样?请回答.

But not able to record with these. I searched a lot for this but wasn't able to get some relevant post. Some posts say that it is not possible.If its not possible then why so? Please answer.

推荐答案

问题是 kAudioFormatMPEGLayer3 不支持 AVAudioRecorder.

或者,您可以使用 kAudioFormatAppleIMA4 进行录音.

Alternatively you can use kAudioFormatAppleIMA4 for your recording purpose.

最后,您可以编写自己的编码逻辑,将 kAudioFormatAppleIMA4 转换为 MP3 格式.

Finally you can write your own encoding logic to convert kAudioFormatAppleIMA4 in to MP3 Format.

用于录制目的的其他支持编码是

The other supported encoding for Recording purpose are

kAudioFormatMPEG4AAC   
kAudioFormatAppleLossless  
kAudioFormatAppleIMA4   
kAudioFormatiLBC 
kAudioFormatULaw 
kAudioFormatLinearPCM 

有关更多信息,您可以参考这个 SO 的帖子.

For more info you can refer to this post of SO.

这篇关于如何以 .mp3 格式录制音频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆