<p>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:</p>

<p><code>ffmpeg -i test.mp3 -acodec libfaac -ab 163840 dest.aac</code></p>

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

<p>Thanks!  </p>

There are only three free AAC encoders that I know of that are available through a commandline interface:
FAAC (LPGL), which is honestly pretty bad (the quality is going to be significantly worse than LAME at the same bitrate).  Its fine though if you're willing to go for higher bitrates (>>128kbps) and need AAC for compatibility, not quality reasons.  The most common way to use FAAC is through ffmpeg, as libfaac.
Nero AAC, the commandline encoder for which is available for free under Windows and Linux, but only for noncommercial use (and is correspondingly closed-source).
ffmpeg's AAC encoder, which is still under development and while I believe it does technically work, it is not at all stable or good or even fast, since its still in the initial stages.  Its also not available in trunk, as far as I know.
(Edit: Seems iTunes might have one too, I suspect its terms of use are similar to Nero's.  AFAIK its quality is comparable.)