FFmpeg AAC VBR Audio Quality Settings Guide
This article provides a quick guide on how to set the audio quality factor for Variable Bitrate (VBR) AAC encoding in FFmpeg. You will learn how to use the correct command-line parameters for both the native FFmpeg AAC encoder and the high-quality external FDK AAC encoder, enabling you to optimize your audio files for the best balance of file size and sound clarity.
To encode AAC audio with a variable bitrate in FFmpeg, you should use quality-based VBR mode rather than targeting a specific bitrate. This allows the encoder to allocate more data to complex parts of the audio and save space on simpler sections. The exact method depends on which AAC encoder you use.
1. Using the Native
FFmpeg AAC Encoder (aac)
The built-in FFmpeg AAC encoder is available in all standard
installations. To enable VBR, you use the -q:a (or
-qscale:a) option.
- Quality Range: 0.1 to 2.0 (higher is better).
- Recommended Quality:
1.0to1.5is ideal for high-quality stereo music (roughly equivalent to 128kbps–192kbps).
Use the following command to set the quality factor:
ffmpeg -i input.wav -c:a aac -q:a 1.2 output.m4aIn this example, -c:a aac selects the native AAC
encoder, and -q:a 1.2 sets the VBR quality factor to
1.2.
2. Using the
Fraunhofer FDK AAC Encoder (libfdk_aac)
If your version of FFmpeg was compiled with support for the external
library libfdk_aac, you can use it for even better audio
quality. For this encoder, you must use the -vbr flag to
set the quality.
- Quality Range: 1 to 5 (higher is better).
- Recommended Quality:
4(approx. 128kbps per channel) or5(approx. 160kbps per channel) for transparent audio quality.
Use the following command to set the VBR quality:
ffmpeg -i input.wav -c:a libfdk_aac -vbr 5 output.m4aIn this command, -c:a libfdk_aac enables the FDK
encoder, and -vbr 5 sets it to the highest VBR quality
level.
By using these VBR methods instead of constant bitrate (CBR) flags
like -b:a, you ensure your AAC encodes maintain consistent
quality throughout the entire playback duration.