Skip to content

Handle audio and subtitles in the final container

needs review

Automatic stream selection may omit a track you expected or choose a different default. Inspect and map deliberately.

Terminal window
ffprobe -v error -show_streams -of json input.mkv

For a Matroska output that copies video and subtitles while encoding every audio stream to Opus:

Terminal window
ffmpeg -i input.mkv \
-map 0:v -map '0:a?' -map '0:s?' \
-c:v copy -c:a libopus -b:a 128k -c:s copy \
output.mkv

This only works when the target container accepts every selected codec. Streamcopy avoids quality loss but cannot apply filters and does not make an incompatible stream compatible. Image-based subtitles, styled text subtitles, attachments, chapters, and fonts need separate checks.

For MP4, text subtitles commonly need conversion to mov_text, and some source subtitle types cannot be converted meaningfully:

Terminal window
ffmpeg -i input.mkv \
-map 0:v:0 -map '0:a?' -map '0:s?' \
-c:v copy -c:a aac -b:a 192k -c:s mov_text \
output.mp4

Use ffprobe to check stream count, codec, language tags, titles, and dispositions. Then play each audio and subtitle track, check synchronization at several timestamps, and verify that default/forced behavior matches the target platform.