MP4, MKV, WebM: which container should you keep?
Key takeaways
- A container (MP4, MKV, WebM, MPEG-TS) is the file wrapper; a codec (H.264, VP9, AV1, AAC, Opus) is the compression of the audio and video inside it.
- Changing container, called remuxing, is lossless and takes seconds with FFmpeg's -c copy, because the compressed streams are not touched.
- MKV (Matroska, specified in IETF RFC 9559) accepts almost any codec and subtitle format, which makes it the safest choice for archiving downloads.
- MP4 (ISO/IEC 14496-14) has the widest playback support on TVs, phones and editing software, but accepts fewer codec and subtitle combinations.
- WebM is a restricted profile of Matroska designed for the web, limited to VP8, VP9 or AV1 video and Vorbis or Opus audio.

A container is the box, a codec is what is packed inside. MP4, MKV, WebM and MPEG-TS are containers: they hold one or more video, audio and subtitle streams, plus metadata and chapters. H.264, VP9, AV1, AAC and Opus are codecs: they compress those streams. For a downloaded video, MKV is the most tolerant choice for archiving, MP4 the most compatible for playback, and switching between them (remuxing) is lossless as long as the codecs are supported.
What is the difference between a container and a codec?
Think of a shipping crate. The crate (container) has labels, a packing list and compartments; the goods inside (codec streams) were compressed separately. You can move the goods to another crate without unpacking them, which is exactly what remuxing does. Re-encoding, by contrast, means unpacking, rebuilding and repacking the goods, and with lossy codecs a little quality is lost each time.
That is why a sentence like “convert MKV to MP4” can mean two very different operations. The fast, lossless one is almost always what you want.
What can each container hold?
| MP4 | MKV (Matroska) | WebM | MPEG-TS | |
|---|---|---|---|---|
| Specification | ISO/IEC 14496-14 (on ISO base media file format) | IETF RFC 9559 | Matroska profile by the WebM Project | ISO/IEC 13818-1 |
| Typical video codecs | H.264, HEVC, AV1 | Practically any | VP8, VP9, AV1 | H.264, HEVC, MPEG-2 |
| Typical audio codecs | AAC, AC-3, Opus (support varies) | Practically any, including FLAC | Vorbis, Opus | AAC, MP3, AC-3 |
| Subtitles | Limited (mov_text / timed text) | SRT, ASS/SSA, PGS, WebVTT and more | WebVTT | Teletext, DVB subtitles |
| Chapters | Yes | Yes, rich | Yes | No |
| Strong point | Plays everywhere | Flexibility, archiving | Open web, royalty-free | Broadcasting, resilient to cuts |
Matroska is built on EBML, a binary format inspired by XML, which makes it extensible. Its 2024 publication as RFC 9559 gave it a formal IETF specification. The Library of Congress format descriptions are a useful neutral reference if you need to justify a preservation choice.
Which container should I choose for downloaded video?
- Personal archive or research collection: MKV. It accepts whatever codecs the source used, keeps several audio tracks and every subtitle format, and supports attachments and rich metadata.
- Playback on a TV, phone or in a video editor: MP4, provided the codecs are H.264 or HEVC with AAC. AV1 in MP4 is valid but needs a recent decoder.
- Publishing on a website: WebM or MP4, depending on the codecs you serve.
- Recording a live stream: MPEG-TS first (a truncated file stays playable), then remux to MKV or MP4. See how to record HLS live streams.
With yt-dlp, --merge-output-format mkv chooses the container used when audio and video are merged, and --remux-video mp4 changes the container after download without re-encoding when the codecs allow it.
How do I change container without losing quality?
With FFmpeg, stream copy does the job:
# MKV to MP4, every stream copied as is
ffmpeg -i input.mkv -map 0 -c copy output.mp4
# MP4 for the web: index at the start of the file
ffmpeg -i input.mp4 -c copy -movflags +faststart web.mp4
# MPEG-TS recording to MKV
ffmpeg -i recording.ts -map 0 -c copy recording.mkv
-map 0keeps every stream (all audio tracks, subtitles), not just the default video and audio.-c copycopies the compressed data.
If FFmpeg refuses with an error such as “codec not currently supported in container”, the target container cannot hold one of the streams. Typical cases: ASS or PGS subtitles into MP4, or FLAC into an older MP4 toolchain. Either drop that stream, convert only that stream (for example -c:s mov_text for text subtitles), or keep MKV.
MKVToolNix, a free graphical tool, does the same for Matroska files and lets you add or remove tracks, set languages and edit chapters without command lines.
How do I check what is inside a file?
Do not trust the extension. Inspect the file:
ffprobe -hide_banner input.mkv
Or open it in MediaInfo, which shows container, codecs, bitrates, languages and subtitle formats in a readable view. You will often discover that a “.mp4” from a website is really a fragmented MP4, or that an MKV holds plain H.264 and AAC and can be remuxed to MP4 in seconds.
What about subtitles and multiple audio tracks?
This is where containers differ most. MKV stores any number of audio tracks and subtitle streams with language tags, which is ideal for content you want to keep in several languages. MP4 stores text subtitles in its own timed-text format and does not accept image-based or styled ASS subtitles. Our subtitles guide explains SRT, WebVTT and TTML, and the audio guide covers what to do with separate audio tracks.
Why will my file not play on a TV, phone or editor?
When a device rejects a file, the container is rarely the real culprit. Check the codecs first, then pick the combination the device is most likely to accept:
| Target | Safest combination | Notes |
|---|---|---|
| Older smart TVs and set-top boxes | MP4 with H.264 video and AAC audio | Many older models ignore MKV subtitles and cannot decode AV1 or Opus |
| iPhone, iPad, QuickTime | MP4 or MOV with H.264 or HEVC and AAC | WebM and MKV generally need a third-party player such as VLC |
| Web pages (HTML video element) | MP4 (H.264/AAC) or WebM (VP9 or AV1 with Opus) | Add -movflags +faststart to MP4 so playback can start before the download ends |
| Video editing software | MP4 or MOV | Many editors import MP4 and MOV more reliably than MKV or WebM |
| Long-term archive | MKV | Keeps every track, chapter and subtitle without conversion |
How do I repair a fragmented or slow-starting MP4?
Files assembled from streaming segments are often fragmented MP4, or have their index (the moov atom) at the end. Both play in VLC but can confuse older players and slow down web playback. A stream-copy remux fixes it in seconds and changes no pixels:
ffmpeg -i input.mp4 -map 0 -c copy -movflags +faststart output.mp4
The same approach rescues a WebM that a device refuses: if the codecs are VP9 and Opus, try MKV first (-c copy into .mkv), because MP4 support for Opus varies between players. Only re-encode, once and from the best source, when the target device cannot decode the codec at all.
Key rules to remember
- Container changes are lossless; codec changes are not.
- Choose MKV when in doubt, MP4 when compatibility matters.
- Always inspect with ffprobe or MediaInfo before converting.
- Never re-encode just to change an extension.
- The choice of codec matters more for quality and file size than the choice of container.
Open-source tools in this guide
| Tool | Licence |
|---|---|
| FFmpeg | LGPL 2.1+ (some builds GPL) |
| MKVToolNix | GPL 2.0 |
| MediaInfo | BSD-style (BSD-2-Clause) |
Frequently asked questions
Does converting MKV to MP4 reduce quality?
Not if you remux: ffmpeg -i input.mkv -c copy output.mp4 copies the compressed streams unchanged. Quality is only lost when you re-encode, which converters often do by default. Remuxing works as long as MP4 supports the codecs inside the MKV.
Why won't my TV play an MKV file?
Usually it is not the container but a codec inside it, such as AV1 or an unusual audio format, that the TV cannot decode. Check with MediaInfo or ffprobe. If the codecs are H.264 and AAC, remuxing to MP4 often solves the problem without re-encoding.
Is WebM better than MP4?
Neither is better in itself. WebM guarantees royalty-free codecs and plays in every modern browser; MP4 has broader support on hardware players and editing software. For a personal archive, MKV can hold the content of either without conversion.
What is the difference between MP4 and M4A?
They share the same container format. The .m4a extension signals an MP4 file that contains only audio, usually AAC. Media players use the extension as a hint, but the internal structure is the same ISO base media file format.
What does -movflags +faststart do?
It moves the MP4 index (the moov atom) to the start of the file. A player or browser can then begin playback before the whole file has been read, which matters for files you put on a web server or share online.
Sources and open data
- RFC 9559: Matroska Media Container Format Specification · IETF / RFC Editor
- WebM container guidelines · WebM Project
- Sustainability of Digital Formats (format descriptions) · Library of Congress
- FFmpeg formats documentation (muxers and demuxers) · FFmpeg project
Related guides
- AV1 vs VP9 vs H.264
Compare AV1, VP9, H.264 and HEVC for downloaded video: efficiency, compatibility, royalties and archiving, plus how to pick a codec with yt-dlp and FFmpeg.
- FFmpeg for video files
FFmpeg commands for downloaded video: merge separate audio and video, remux TS to MP4 without quality loss, cut clips, join parts and convert only when needed.
- Subtitles SRT / VTT
Download subtitles and captions with yt-dlp, convert WebVTT to SRT with FFmpeg, embed or burn them in, and understand SRT, VTT, TTML and ASS formats.
- HLS / m3u8
What an .m3u8 playlist really is, how HLS splits video into segments, and how to save an HLS stream to one clean MP4 with yt-dlp or FFmpeg.
- Audio: Opus, AAC, MP3
Save the soundtrack of a video losslessly: identify Opus, AAC or MP3 audio, copy it with FFmpeg or yt-dlp, and convert only when a device requires it.