FFmpeg - Encode AAC: Difference between revisions
Created page with "Category:FFmpeg Category:AAC <pre> ffmpeg -i <input.file> -c:a libfdk_aac -ac 2 -b:a 128k <output.file> </pre> These settings target a specific bit rate, with less variation between samples. It gives you greater control over file size, and it is compatible with the HE-AAC profile. As a rule of thumb, for audible transparency, use 64 kBit/s for each channel (so 128 kBit/s for stereo, 384 kBit/s for 5.1 surround sound).<br/> Set the bit rate with the <code>-b:a</co..." |
No edit summary |
||
| Line 1: | Line 1: | ||
[[Category:FFmpeg]] | [[Category:FFmpeg]] | ||
[[Category:AAC]] | [[Category:AAC]] | ||
AAC (Advanced Audio Coding) is a modern, efficient audio codec widely used for streaming, broadcasting, and high‑quality distribution. FFmpeg supports several AAC encoders, but libfdk_aac remains one of the highest‑quality options when available. | |||
This article provides a practical, reliable command for encoding AAC audio with predictable output quality and file size, and explains the reasoning behind the settings. | |||
== Overview == | |||
libfdk_aac is an external library that offers excellent audio quality, especially at low and medium bitrates. When you need consistent bitrate, stereo output, or compatibility with HE‑AAC modes, the -b:a (bitrate) approach is usually the most predictable. | |||
The following command encodes an input file to AAC using libfdk_aac, targeting a specific bitrate: | |||
<pre> | <pre> | ||
ffmpeg -i <input.file> -c:a libfdk_aac -ac 2 -b:a 128k <output.file> | ffmpeg -i <input.file> -c:a libfdk_aac -ac 2 -b:a 128k <output.file> | ||
</pre> | </pre> | ||
== Explanation of Parameters == | |||
Reference | === -c:a libfdk_aac === | ||
Selects the excellent-quality Fraunhofer FDK AAC encoder. | |||
=== -ac 2 === | |||
Forces 2 audio channels (stereo). | |||
=== -b:a 128k === | |||
Sets the audio bitrate. | |||
== Choosing the Right Bitrate == | |||
When targeting audible transparency, a simple rule of thumb is: | |||
* 64 kbit/s per channel | |||
* Stereo: 128 kbit/s | |||
* 5.1 surround: 384 kbit/s | |||
== HE-AAC Compatibility == | |||
libfdk_aac can produce AAC-LC, HE-AAC, and HE-AAC v2. Bitrate-based encoding (-b:a) ensures profile compatibility. | |||
== Common Variations == | |||
=== High-quality stereo (192 kb/s) === | |||
<pre> | |||
ffmpeg -i input.wav -c:a libfdk_aac -b:a 192k output.m4a | |||
</pre> | |||
=== Low-bitrate streaming (64 kb/s HE-AAC) === | |||
<pre> | |||
ffmpeg -i input.wav -c:a libfdk_aac -b:a 64k output.m4a | |||
</pre> | |||
=== Surround sound (5.1 – 384 kb/s) === | |||
<pre> | |||
ffmpeg -i input.wav -c:a libfdk_aac -ac 6 -b:a 384k output.m4a | |||
</pre> | |||
== Reference == | |||
https://trac.ffmpeg.org/wiki/Encode/AAC | |||
Latest revision as of 14:36, 14 March 2026
AAC (Advanced Audio Coding) is a modern, efficient audio codec widely used for streaming, broadcasting, and high‑quality distribution. FFmpeg supports several AAC encoders, but libfdk_aac remains one of the highest‑quality options when available.
This article provides a practical, reliable command for encoding AAC audio with predictable output quality and file size, and explains the reasoning behind the settings.
Overview
libfdk_aac is an external library that offers excellent audio quality, especially at low and medium bitrates. When you need consistent bitrate, stereo output, or compatibility with HE‑AAC modes, the -b:a (bitrate) approach is usually the most predictable.
The following command encodes an input file to AAC using libfdk_aac, targeting a specific bitrate:
ffmpeg -i <input.file> -c:a libfdk_aac -ac 2 -b:a 128k <output.file>
Explanation of Parameters
-c:a libfdk_aac
Selects the excellent-quality Fraunhofer FDK AAC encoder.
-ac 2
Forces 2 audio channels (stereo).
-b:a 128k
Sets the audio bitrate.
Choosing the Right Bitrate
When targeting audible transparency, a simple rule of thumb is:
- 64 kbit/s per channel
- Stereo: 128 kbit/s
- 5.1 surround: 384 kbit/s
HE-AAC Compatibility
libfdk_aac can produce AAC-LC, HE-AAC, and HE-AAC v2. Bitrate-based encoding (-b:a) ensures profile compatibility.
Common Variations
High-quality stereo (192 kb/s)
ffmpeg -i input.wav -c:a libfdk_aac -b:a 192k output.m4a
Low-bitrate streaming (64 kb/s HE-AAC)
ffmpeg -i input.wav -c:a libfdk_aac -b:a 64k output.m4a
Surround sound (5.1 – 384 kb/s)
ffmpeg -i input.wav -c:a libfdk_aac -ac 6 -b:a 384k output.m4a