开发者

Convert .wav file to .mp3

I want to convert an audio file saved with .wav file format to a file with .mp3 format.

Please suggest that how can I achieve this through Objective C coding.

Thanks开发者_运维百科 in advance.


You'll have to use LAME to do this. Apple doesn't ship an MP3 encoder due to patent issues.


Take a look at the AVFoundation framework, especially the AVAssetWriter class. It’s very powerful, but it takes some time to digest. There is a nice blog entry by Chris Adamson on decoding songs from the iPod library to PCM. It’s exactly the other way you want it, but it’s a good start.


I don't think there is an API in AVFoundation for that. I think If you use AVAssetWritter you can write *.m4a (AVFileTypeAppleM4A) files which are *.acc, I believe. (ACC are lighter and better than mp3, so a good alternative to mp3)

If you use CoreAudio probably is going to be a lot much work but it should be possible to write mp3. I asked how to read mp3 using coreaudio in apple-lists like 2 years ago and I got code that makes speakHere sample app able to read *.mp3 ;)

Perhaps, you are interested: Newbie trying to play mp3 files instead wav files


CoreAudio framework has an API called Extended Audio File Services, which enables converting from one format to another. See here: http://developer.apple.com/library/ios/#samplecode/iPhoneExtAudioFileConvertTest/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009222-Intro-DontLinkElementID_2


Following on to sbooth's answer about LAME, there's a separate post on StackOverflow that gives you what you need to create a .a for the library: How can I compile lame as static library(.a) for armv6 and armv7 of iPhone?

Once you have done that, follow LAME's docs and you're set.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜