Ch. 12 · Audio Codecs

한국어日本語
7 min

Audio Compatibility by Container, and How to Check

For audio too, a codec is not a container. Which audio codecs go into MP4, WebM, MKV, and MPEG-TS, where things get blocked, and the order in which to check.

In Chapter 10 you learned that a container and a codec are different things. The same goes for audio, so the problem of "it's an .mp4 but there's no sound" usually happens because the container can be read but the audio codec can't be decoded. The table below lists common combinations.

ContainerCommonly used audio codecsNotes
MP4 / M4AAAC, MP3, AC-3, E-AC-3The most universal. Opus and FLAC can be held per the spec, but support may vary by player and device
WebMOpus, VorbisThese are the only two audio codecs the WebM spec allows. It cannot hold AAC
MKVAlmost every codecAAC, Opus, FLAC, AC-3, E-AC-3, and most others work. Playback is up to the player
MPEG-TSAAC, MP3, AC-3, E-AC-3The combinations you meet in broadcast and HLS
OggVorbis, Opus, FLACThe open-format family
WAVPCMUncompressed. For editing and exchange
FLAC (file)FLACThe container itself is a FLAC stream

"Possible" and "plays everywhere" are different things. The notes column follows commonly known specifications, and device-by-device support has to be checked yourself.

The safest combinations

If you need to distribute widely across many devices, MP4 + H.264 + AAC-LC is known to be the most dependable combination; for a web-focused setup with open codecs, it is WebM + VP9/AV1 + Opus. If you need surround, putting AC-3/E-AC-3 in MP4/TS is common on broadcast, set-top box, and AV receiver gear.

What to check when there's no sound

  1. 1Use ffprobe to check whether there is an audio stream, and which codec it is. Surprisingly many files have no audio stream at all.
  2. 2Check whether the target player or device supports that audio codec. In a browser, you can check the video side with the codec support checker.
  3. 3Check whether the channel count and sampling rate are allowed in the target environment. For example, the downmix when 5.1 is sent to stereo equipment.
  4. 4If the codec is the problem, re-encode only the audio (-c:v copy -c:a aac); if the container is the problem, remux.
Convert only the audio to AAC and leave the video as is (making AC-3/DTS in an MKV MP4-compatible)
# Copy the video + convert the audio to AAC stereo
ffmpeg -i in.mkv -c:v copy -c:a aac -b:a 160k -ac 2 out.mp4

# If the audio is already AAC, change only the container without re-encoding
ffmpeg -i in.mkv -c copy out.mp4
In the field: audio and video sync

AAC encoders put a short delay (priming samples) at the start, and if the container doesn't record that value accurately, the audio can drift slightly out of sync with the video, or gapless playback can break. You can check whether a remux without re-encoding is possible with the MKV to MP4 remux feasibility checker, see the stream information inside a file with the video file info inspector, and put the commands together with the help of the ffmpeg command builder.

Wrapping up this chapter

Audio codecs share their philosophy with video codecs. Discard what people can't perceive (perceptual coding), pick the generation that fits the purpose (AAC, Opus, AC-3, FLAC), and finish with compatibility checks and measurement. Within the scope of this chapter, this site does not yet have any audio data it measured itself, so the numbers cover only ranges known from standards and official documents. You can pick up the video-side measurements in the measurement articles.

RemuxRemux

Changing only the container without re-encoding the streams.

DownmixDownmix

Folding multichannel audio such as 5.1 into fewer channels, such as stereo.

Gapless playbackGapless playback

Playing tracks back to back with no break between them. Requires accurate encoder delay information.

VorbisVorbis

An open lossy audio codec from the Ogg family. The generation before Opus.

Check yourself

Which audio codecs can a WebM container generally hold?