Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 698
iPhoneDev Avatar asked Feb 02 '11 07:02

iPhoneDev


3 Answers

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

like image 148
sbooth Avatar answered Sep 24 '22 14:09

sbooth


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.

like image 44
zoul Avatar answered Sep 21 '22 14:09

zoul


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

like image 29
nacho4d Avatar answered Sep 21 '22 14:09

nacho4d