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.
"Possible" and "plays everywhere" are different things. The notes column follows commonly known specifications, and device-by-device support has to be checked yourself.
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.
-c:v copy -c:a aac); if the container is the problem, remux.# 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.mp4AAC 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.
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.
Changing only the container without re-encoding the streams.
Folding multichannel audio such as 5.1 into fewer channels, such as stereo.
Playing tracks back to back with no break between them. Requires accurate encoder delay information.
An open lossy audio codec from the Ogg family. The generation before Opus.
Which audio codecs can a WebM container generally hold?