iPhoneDev
iPhoneDev

Reputation: 1557

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.

Upvotes: 7

Views: 9479

Answers (5)

William Power
William Power

Reputation: 696

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.

Upvotes: 0

sbooth
sbooth

Reputation: 16976

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

Upvotes: 6

Itamar Katz
Itamar Katz

Reputation: 9645

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

Upvotes: 0

nacho4d
nacho4d

Reputation: 45108

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

Upvotes: 2

zoul
zoul

Reputation: 104065

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.

Upvotes: 4

Related Questions