Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I can issue this command:

ffmpeg -i input.mp3 -acodec alac -ab 128k -ar 48000 -ac 2 -y output.m4a 

to create a m4a file.

But when I issue this command

ffmpeg -i input.mp3 -acodec alac -ab 128k -ar 48000 -ac 2 -y output.aac

ffmpeg is throwing an error saying

Could not write header for output file #0 (incorrect codec parameters ?).

Also, the size of the m4a file is really almost 5.8 times larger than the original file, which is absolutely not what I wanted and why I wanted to convert to AAC.

share|improve this question

1 Answer

up vote 10 down vote accepted

How can I convert to AAC?

This is the most basic FFmpeg command to convert input to AAC audio using the popular and high-quality FAAC encoder:

ffmpeg -i input.mp3 -c:a libfaac output.m4a

To change the quality, you have two options:

  • For variable bitrate (VBR), use the -q:a option. For example, -q:a 100 is the default quality of 100%, and higher means better. Values range from 10 to 500.

  • For fixed bitrate (CBR), use the -b:a option, for example -b:a 128k. 128 kBit/s should be good enough for most situations.


What if I don't have libfaac?

Some versions of FFmpeg do not have libfaac (for licensing reasons). 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 gives you the following options for AAC:

  • -c:a libfaac support if you install FAAC.
  • -c:a libfdk-aac, the Fraunhofer AAC encoder. This is another very good alternative to FAAC and should deliver even better quality than FAAC.

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.

share|improve this answer
@slhck can you site a source for the Values range from 10 to 500? Thank you sir – Steven Penny Feb 27 at 5:45
@StevenPenny The FAAC help mentions this for the -q parameter. FFmpeg should map the values in libavcodec/libfaac.c, and it's mentioned in the AAC Encoding Guide on the FFmpeg wiki. I still have the slight feeling that this is not accurate enough for values lower than 10 though. 500 is correct as the upper bound—I tested this. – slhck Feb 27 at 6:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.