Encode Audio to AAC-HE with FFmpeg

This article provides a quick guide on how to encode audio streams into High-Efficiency AAC (HE-AAC) using FFmpeg. You will learn about the required external library, the specific commands for both HE-AAC Version 1 and Version 2, and the optimal bitrate configurations for low-bandwidth audio compression.

Prerequisites: The libfdk_aac Library

FFmpeg’s native AAC encoder does not support High-Efficiency profiles (HE-AAC). To encode to HE-AAC, you must use the Fraunhofer FDK AAC library (libfdk_aac).

Because this library is under a non-free license, it is not included in standard, pre-compiled FFmpeg builds. You must use a build of FFmpeg compiled with the --enable-libfdk-aac flag (and usually --enable-nonfree). You can verify if your FFmpeg installation supports it by running:

ffmpeg -codecs | grep fdk

How to Encode to HE-AAC Version 1 (v1)

HE-AAC v1 is ideal for stereo audio at bitrates between 48kbps and 64kbps. It uses Spectral Band Replication (SBR) to reconstruct high-frequency signals.

Use the following command to encode an audio file to HE-AAC v1:

ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he -b:a 64k output.m4a

How to Encode to HE-AAC Version 2 (v2)

HE-AAC v2 is optimized for even lower bitrates, typically between 24kbps and 32kbps for stereo. It adds Parametric Stereo (PS) to the SBR technology. Note that HE-AAC v2 only supports stereo input.

To encode to HE-AAC v2, use this command:

ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he_v2 -b:a 32k output.m4a

Bitrate Selection Guide

Using the correct profile for your target bitrate ensures the best possible audio quality: