Containers overview
A container (or “muxer format”) is the file that holds your encoded video, audio, subtitles, chapters and metadata together and keeps them in sync. It does not change quality: moving streams between containers is a remux and, with -c copy, is lossless and takes seconds. The file extension is only a label; what matters is which streams are inside and whether your player understands them.
Which container should I use?
Section titled “Which container should I use?”| Container | Extensions | Use it for | Watch out for |
|---|---|---|---|
| Matroska | .mkv, .mka, .mks | Archives and releases: any codec, many tracks, ASS/PGS subtitles, fonts, chapters | Not accepted by most phones, TVs and web browsers |
| MP4 | .mp4, .m4a, .m4v | Sharing, web, phones, TVs, streaming | Text subtitles only as mov_text; no ASS or PGS |
| WebM | .webm | Browser playback with VP8/VP9/AV1 and Vorbis/Opus | Nothing else fits: no H.264, AAC or SRT |
| MOV | .mov | Editing and mezzanine files (ProRes, DNxHR), Apple workflows | Looks like MP4 but accepts codecs MP4 players may not |
| Ogg | .ogg, .oga, .opus | Opus, Vorbis and FLAC audio; Theora video | Poor video container; .opus is Opus in Ogg |
| AVI | .avi | Playing old files | No real timestamps, no modern features; remux old files out of it |
For a file you will keep or edit later, use MKV. For a file you will send to someone or put on a website, use MP4 (H.264 or HEVC plus AAC or Opus) or WebM. ISOBMFF is the shared base format behind MP4, MOV, HEIF and AVIF.
Remuxing
Section titled “Remuxing”Copy streams from one container to another without re-encoding:
ffmpeg -i input.mkv -c copy output.mp4mkvmerge -o output.mkv input.mp4This only works if the target container can hold the streams. Without -map, FFmpeg keeps one video, one audio and at most one subtitle stream, and it can drop the subtitles without complaint when they cannot be copied, so check the result with ffprobe. Subtitles are the usual casualty; see Audio and subtitle handling and the subtitle formats overview.
What containers do not do
Section titled “What containers do not do”- They do not fix a bad encode or add compatibility to a codec: an MP4 holding a codec your TV cannot decode will not play.
- They do not decide the codec. A
.mp4can hold H.264, HEVC, AV1 or VP9; check withffproberather than trusting the extension. - Colour and HDR signalling live partly in the bitstream and partly in the container. Remuxing between families can drop or rewrite the container-level part, so verify HDR files after remuxing. See Preserve colour and HDR.