Search code examples
rubymp3aacm4a

How do I programmatically convert mp3 to an itunes-playable aac/m4a file?


I've been looking for a way to convert an mp3 to aac programmatically or via the command line with no luck. Ideally, I'd have a snippet of code that I could call from my rails app that converts an mp3 to an aac. I installed ffmpeg and libfaac and was able to create an aac file with the following command:

ffmpeg -i test.mp3 -acodec libfaac -ab 163840 dest.aac

When i change the output file's name to dest.m4a, it doesn't play in iTunes.

Thanks!


Solution

  • FFmpeg provides AAC encoding facilities if you've compiled them in. If you are using Windows you can grab full binaries from here

    ffmpeg -i source.mp3 -acodec libfaac -ab 128k dest.aac
    

    I'm not sure how you would call this from ruby.

    Also, be sure to set the bitrate appropriately.