Handle audio and subtitles in the final container
Automatic stream selection may omit a track you expected or choose a different default. Inspect and map deliberately.
ffprobe -v error -show_streams -of json input.mkvFor a Matroska output that copies video and subtitles while encoding every audio stream to Opus:
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.mkvThis 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:
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.mp4Validate
Section titled “Validate”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.