Dolby audio codecs and Atmos
37c3317fd058; modified for Encode Wiki · CC BY-SA 4.0Dolby has several unrelated-looking things under one name: AC-3 and E-AC-3 are lossy surround codecs, TrueHD is a lossless one, AC-4 is a newer lossy one, and Atmos is an immersive-audio system that rides on top of E-AC-3, TrueHD and AC-4. If you work with Blu-rays, streaming rips or home theatre files you will meet all of them. The practical rule: copy Dolby tracks rather than re-encoding them, because FFmpeg can only make plain channel-based AC-3, E-AC-3 and (experimentally) TrueHD, with no Atmos.
The codecs
Section titled “The codecs”| Codec | Type | What it is |
|---|---|---|
| AC-3 (Dolby Digital) | Lossy | The original 5.1 codec: DVD, broadcast, Blu-ray core tracks. Up to 640 kbit/s. Every surround device plays it. |
| E-AC-3 (Dolby Digital Plus) | Lossy | AC-3’s successor: more efficient, 32 kbit/s to 6 Mbit/s, up to 7.1 discrete channels. The main surround codec of streaming services; also how Atmos reaches streaming. Not bitstream-compatible with AC-3, but E-AC-3 decoders also decode AC-3. |
| TrueHD | Lossless | MLP-derived lossless codec used on Blu-ray: 44.1–192 kHz, up to 24-bit, up to 16 channels in the format. Blu-ray limits it to eight channels at 96 kHz or six at 192 kHz. Carries Atmos on disc. |
| AC-4 | Lossy | Newer broadcast and streaming codec with multiple presentations (languages, dialogue enhancement) and Atmos support. Not compatible with AC-3 or E-AC-3. |
On Blu-ray, a TrueHD track is interleaved with an AC-3 version in the same stream for players that cannot decode TrueHD. FFmpeg and eac3to expose the two as separate tracks, so you can keep just the lossless one.
Atmos is not a codec
Section titled “Atmos is not a codec”Atmos is a production and rendering system. A mix is a channel bed (for example 7.1.2) plus positioned audio objects and metadata, and the player’s renderer maps that to whatever speakers or headphones are present. That payload is carried by a normal Dolby codec:
- TrueHD Atmos on Blu-ray: the usual lossless 7.1/5.1/stereo presentations, rendered from the full mix, plus an extra substream with the object data.
- E-AC-3 with JOC (Joint Object Coding) on streaming: a lossy 5.1 or 7.1 mix rendered from the full mix, plus side data from which an Atmos decoder reconstructs the objects. Decoders without Atmos support play the channel mix.
- AC-4 for broadcast and some streaming.
So an E-AC-3 or TrueHD file is not necessarily Atmos; check the profile. ffprobe reports Atmos streams as “Dolby Digital Plus + Dolby Atmos” or “Dolby TrueHD + Dolby Atmos” in the profile field.
What FFmpeg can and cannot do
Section titled “What FFmpeg can and cannot do”| Task | FFmpeg |
|---|---|
| Copy any Dolby track into another container | Yes (-c copy). Atmos survives. |
| Encode plain AC-3 or E-AC-3 from PCM | Yes: ac3 and eac3, up to 5.1. A 7.1 input is silently downmixed to 5.1. |
| Encode TrueHD from PCM | Experimental: truehd, up to 5.1, needs -strict -2. Bit-exact on decode. |
| Encode AC-4 | No. |
| Create Atmos | No. Needs Dolby’s Atmos tools and licensed encoders. |
| Decode Atmos | Decodes the backward-compatible 7.1 or 5.1 mix and ignores the object data, so height and object positioning are lost. |
Re-encoding an Atmos track with FFmpeg to AC-3, E-AC-3, AAC or Opus permanently discards the object data. If you need a compatibility copy, make it additionally and keep the original track.
Commands
Section titled “Commands”Copy a Dolby track into a new file without touching the audio:
ffmpeg -i input.mkv -map 0:a:0 -c:a copy output.mkaEncode a 5.1 PCM master to AC-3 or E-AC-3:
ffmpeg -i input.wav -c:a ac3 -b:a 640k output.ac3ffmpeg -i input.wav -c:a eac3 -b:a 640k output.eac3Use 448 kbit/s for 5.1 AC-3 if the target doesn’t need the maximum. Stereo is typically 192 kbit/s. The encoder has a lot of metadata options (-dialnorm, -dmix_mode, -center_mixlev and others) that matter for broadcast delivery and rarely otherwise; the defaults are fine for a compatibility track.
Encode lossless TrueHD (5.1 or fewer channels):
ffmpeg -i input.wav -c:a truehd -strict -2 output.thdThis is experimental and rarely worth it; if you just want lossless surround, use FLAC.
AC-3, E-AC-3 and TrueHD go into MP4 (E-AC-3 and AC-3) or Matroska (all). MP4 labels them ac-3 and ec-3. Most TVs and receivers want a bitstream passthrough over HDMI to get Atmos, which means copying the track, not decoding it.
When to choose what
Section titled “When to choose what”- Remuxing a disc or streaming rip: keep the original track.
- A surround compatibility copy for a TV: E-AC-3 or AC-3 at 448–640 kbit/s. For most people AAC or Opus are better codecs, but only the Dolby ones pass through to an AV receiver.
- Lossless surround you encode yourself: FLAC.
- Authoring Atmos: professional Dolby tools; see spatial and immersive audio for the open alternatives.