How can I convert to AAC?
This is the most basic FFmpeg command to convert input to AAC audio using the highest quality AAC FFmpeg has.
libfdk_aac is the Fraunhofer AAC encoder, and it is available when you compiled FFmpeg with support for it.
ffmpeg -i input.mp3 -c:a libfdk_aac output.m4a
To change the quality, you have two options:
For variable bitrate (VBR), use the
-vbr option. For example,
-vbr 4 is a good choice (roughly 128 kBit/s for stereo audio). Higher means better. Values range from 1 to 5.
ffmpeg -i input.mp3 -c:a libfdk_aac -vbr 4 output.m4a
For fixed bitrate (CBR), use the
-b:a option, for example
-b:a 128k. 128 kBit/s should be good enough for most situations. You can often choose something lower as well.
ffmpeg -i input.mp3 -c:a libfdk_aac -b:a 128k output.m4a
What if I don't have
Some versions of FFmpeg do not have
libfdk_aac (for licensing reasons). The same goes for other AAC encoders such as
libfaac. If that's the case, you have various options:
Compile FFmpeg yourself.
There are guides on the FFmpeg Wiki. Compiling is easy on Linux, moderately easy on OS X, and rather hard on Windows. When you follow the compilation guides and install the appropriate libraries before, FFmpeg now gives you the following options for AAC:
Use another encoder.
FFmpeg typically has other AAC encoders, which you can use as a "fallback" if neither FAAC nor Fraunhofer AAC are available. Neither of these support VBR encoding, so you need to supply a constant bit rate with
-b:a 192K, for example.
-c:a aac -strict experimental, is the "native" FFmpeg AAC encoder, but it is considered experimental (works fine though). Its quality is rather mediocre.
-c:a libvo_aacenc is shipped with most static builds of FFmpeg. It doesn't provide good quality though—even worse than the native AAC encoder—so you should avoid that if possible.
But honestly, if you care about quality, you should probably compile FFmpeg yourself.
There were some problems with your original approach:
alac is not AAC. ALAC is the Apple Lossless Audio Codec, whereas AAC is Advanced Audio Coding.
That's why your output is larger than the input, because in contrast to MP3, ALAC is still compressed, but it needs to be lossless – that's why it needs to store more data.
.aac is not an output container for ALAC audio. If you use AAC, that should work. I would use MP4 or M4A though.