MP4 vs MKV vs WebM: Browser Support, Codecs, Subtitles, and Which Container to Use
Key takeaways
MP4 is the safest choice for web and device playback, MKV holds almost any codec plus multiple audio and subtitle tracks but lacks native browser support, and WebM pairs VP9 or AV1 with Opus for the open web. The post covers recommendations by scenario and remuxing between them with FFmpeg.
Introduction
Containers (muxing formats) are wrappers that bundle video, audio, subtitles, and chapters into one file. Unlike codecs, “where it plays” is usually determined by container and platform policy. MP4 is nearly standard on mobile and web, MKV is strong for multiple subtitles and audio, and WebM is tailored for web and royalty-free stack. The split of responsibilities is worth stating precisely because most playback problems come from confusing the two layers. The codec (H.264, HEVC, VP9, AV1, AAC, Opus) compresses the actual pictures and sound. The container stores the compressed packets of each stream, interleaves them so audio and video for the same moment sit close together in the file, and adds timestamps, an index for seeking, track languages, chapters and metadata. A player has to understand both: “this MKV won’t play” often means the player handles Matroska fine but has no decoder for the HEVC or DTS stream inside. Conversely, moving streams to a different container (remuxing) is fast and lossless, but only possible when the target container allows those codecs.
When to Use MP4, MKV, or WebM?
| Aspect | MP4 | MKV | WebM |
|---|---|---|---|
| Performance & Distribution | Wide compatibility | Good for archive with many tracks | Fits web & royalty stack |
| Usability | Many editing & streaming tools | Flexible subtitles & audio tracks | Need browser & policy check |
| Application Scenario | General distribution | Collection, keeping | Web optimization, VP9/AV1, etc. |
Quick Comparison
| Feature | MP4 (.mp4, M4V) | MKV (.mkv) | WebM (.webm) |
|---|---|---|---|
| Standard & Origin | MPEG-4 Part 14 (ISO), industry standard | Matroska (open spec) | WebM (Matroska-based subset, VP8/VP9/AV1+Opus/Vorbis) |
Web <video> | Very widely supported | Browser & build variations | Chrome/Firefox friendly for VP9/AV1 combinations |
| Mobile & TV | Almost all devices | Some devices restricted | Hardware & app dependent |
| Multiple Subtitles & Audio | Possible but can feel limited in practice | Very flexible | Subtitles mostly external WebVTT or limited embedded |
| Streaming Segments | Commonly used in HLS/DASH fMP4 | Mostly file sharing & archive | Adaptive with MSE+WebM or some DASH environments |
| Typical Codec Combinations | H.264/AAC, HEVC/AAC | Easy to put anything (player decides codec support) | VP9/AV1 + Opus/Vorbis |
Structurally, MP4 (based on Apple’s QuickTime format) is a tree of “boxes”: ftyp identifies the file, moov holds the index — every sample’s size, offset and timestamp — and mdat holds the media data. Because the index lists every sample up front, seeking is a table lookup, but the index can only be written once encoding has finished, which is why it ends up at the end of the file by default. Matroska uses EBML, a binary relative of XML, and stores data in clusters with cues for seeking; it can be written incrementally, so a recording that is cut off by a crash is often still playable, while an MP4 whose moov was never written is not. WebM is Matroska with a restricted list of allowed codecs and elements, which makes it easier for browsers to implement completely.
Format Details
MP4
Feature: Most universal distribution format. Good fit for streaming packagers (fMP4), mobile cameras, and editing tools. Pros
- Best smartphone, tablet, and STB compatibility
- Rich documentation and tools for HLS/DASH integration Cons
- Can be inconvenient when wanting to handle very complex subtitles, chapters, and multilingual tracks as “easily” as MKV FFmpeg: Remux
ffmpeg -i input.mkv -c copy -movflags +faststart output.mp4
This one-liner has two traps. First, without -map, FFmpeg picks only one video, one audio and one subtitle stream by its default rules, so a file with three audio languages silently becomes a file with one — add -map 0 to keep everything. Second, MP4 does not accept SRT or ASS subtitle streams as-is; with subtitles present the command fails with Could not find tag for codec subrip in stream #2, codec not currently supported in container. Convert them with -c:s mov_text (losing ASS styling) or drop them with -sn. The same error appears for audio codecs MP4 players rarely support, such as some DTS or PCM variants inside MKV files.
MKV (Matroska)
Feature: Open container, good for putting multiple audio, subtitles, and chapters in one file. Often preferred in archive and ripping workflows. Pros
- Flexible in track count and metadata representation
- Easy to bundle lossless audio (FLAC) and various subtitle formats Cons
- Some appliances and old devices don’t support playback
- “Just play” in web default player can be less favorable than MP4 FFmpeg: Copy with Subtitles
ffmpeg -i input.mp4 -i subs.srt -c copy -c:s srt output.mkv
MKV’s flexibility is exactly why it dominates archiving: it holds nearly any codec, any number of audio and subtitle tracks with language tags and a default flag, styled ASS subtitles with embedded fonts as attachments, and chapters. The price is playback support. Browsers do not officially support MKV — Chromium-based browsers will sometimes play an MKV that happens to contain WebM-compatible codecs, which misleads people into thinking it works — and many TVs and set-top boxes support only some codecs inside it. Media servers such as Plex or Jellyfin handle this by remuxing or transcoding on the fly for each client, which works but costs CPU on the server.
WebM
Feature: Web-oriented format centered on VP8/VP9/AV1 + Opus/Vorbis. Chosen by services wanting to reduce royalty burden. Pros
- Good fit for royalty-free codec stack
- Can implement adaptive streaming with MSE (Media Source Extensions) Cons
- Apple ecosystem and some encoder pipelines prefer MP4
- Container allows subset of track combinations, not as free as MKV FFmpeg: Create WebM
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a libopus -b:a 128k output.webm
With libvpx-vp9, -b:v 0 is required for -crf to mean constant quality; with a non-zero -b:v, CRF becomes a quality floor inside a bitrate cap, and without -b:v at all older FFmpeg versions applied a default bitrate that made CRF nearly useless. libvpx is also slow at its default settings — adding -row-mt 1 and a -deadline good -cpu-used 2 (or higher for faster, lower-quality encodes) makes a large difference on multi-core machines. For AV1 in WebM, libsvtav1 is currently the practical choice for speed.
Performance & Ecosystem Comparison
“Performance” is dominated by contained codec and decoding hardware rather than container itself. Below is ecosystem & tool comparison assuming same codec.
| Aspect | MP4 | MKV | WebM |
|---|---|---|---|
| Encoding→Distribution Speed | Many packaging tools | Strong for fast copy (remux) | Depends on encoder & preset |
| Editing NLE Compatibility | Very good | Good (varies by project) | Sufficient for web purposes |
| Subtitle UX (single file) | Possible | Often most flexible | WebVTT external linking common |
Visualization: By Distribution Channel
flowchart TD
subgraph mobile_web[Mobile & Wide]
P4[MP4]
end
subgraph archive[Archive & Multilingual]
MKV[MKV]
end
subgraph web_open[Web & Open Codec]
WM[WebM]
end
mobile_web --> P4
archive --> MKV
web_open --> WM
Container overhead itself is small — typically well under one percent of file size for normal-bitrate video — so choosing a container for “smaller files” is rarely meaningful. Where the container does affect performance is in startup and seeking: an MP4 without faststart forces a browser to fetch the end of the file before playing, and a file without a proper seek index (common with MKV files written by streaming tools, or cut with some editors) makes every seek scan the file.
Recommendations by Scenario
| Scenario | Recommendation | Reason |
|---|---|---|
| Pre-YouTube upload encoding | MP4 (H.264 + AAC) | Easy to match platform-recommended combination |
| Personal media server (Plex, etc.) | MKV or MP4 | MKV for subtitles & multi-audio, MP4 for simple playback |
| Web self-hosting (open codec) | WebM or MP4 (fMP4) | Choose by browser & CDN policy |
| Editing intermediate output | Follow project spec (Premiere, etc.) | Export final as MP4/MKV only |
| Copyright & license sensitive | Consider WebM (AV1/VP9+Opus) | Link with codec stack selection |
For recording, I prefer MKV even when the final target is MP4. A screen or stream recording written directly to MP4 is unplayable if the recorder crashes or the disk fills before the index is written; the same recording in MKV loses only the last few seconds. OBS Studio’s default of recording to MKV (and offering a “Remux Recordings” menu item) is a direct response to this failure mode, and remuxing to MP4 afterwards takes seconds because no re-encoding is involved.
Migration Guide
MKV → MP4 (Compatibility Priority)
- Check codec: If H.264/AAC, often can remux with
-c copy. - HEVC/subtitles: If MP4 doesn’t allow combination, re-encode video or separate subtitles to external WebVTT.
- faststart: Apply
-movflags +faststartfor streaming playback.
# Remux MKV to MP4 (if codecs compatible)
ffmpeg -i input.mkv -c copy -movflags +faststart output.mp4
# Re-encode if needed
ffmpeg -i input.mkv -c:v libx264 -preset medium -crf 23 -c:a aac -b:a 128k -movflags +faststart output.mp4
MP4 → WebM
- Re-encode video & audio to VP9/Opus (copy alone usually impossible).
- A/B test resolution & CRF to service standards.
# Convert MP4 to WebM
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a libopus -b:a 128k output.webm
Caution: “Just changing container” is not always possible; contained stream specs must be compatible.
Before any conversion, run ffprobe input.mkv (or ffprobe -v error -show_streams input.mkv for details) and read the codec of each stream. That decides everything: H.264 + AAC can be remuxed to MP4 in seconds; HEVC can be remuxed too, but Apple players require the hvc1 tag (-tag:v hvc1) rather than FFmpeg’s default hev1, or QuickTime and Safari show a black screen with audio; VP9 or AV1 into MP4 is allowed by the spec but less widely supported by players. The re-encode path is the fallback when the codec itself is the problem, and it costs both time and a generation of quality loss.
Deployment Notes
Mixed Usage (e.g., MP4 + H.264 + AAC)
- Base distribution: MP4 + H.264 + AAC.
- High-efficiency variant: Add same content as WebM (AV1+Opus) for users with ample bandwidth.
Fallback Strategy
<video controls>
<source src="clip.webm" type='video/webm; codecs="av01.0.08M.08, opus"'>
<source src="clip.mp4" type='video/mp4'>
</video>
- HLS: Segments are MPEG-TS or fMP4 (CMAF); fMP4 lets the same segments serve both HLS and DASH. WebM adaptive requires separate design.
The fallback order works like the audio case: the browser takes the first source it thinks it can play, so the more efficient AV1 WebM is listed first and MP4 last. The codecs string lets a browser without AV1 support skip the file without downloading it. The MP4 source has no codecs parameter here; adding one (for example codecs="avc1.640028, mp4a.40.2") is better practice, because it lets browsers reject a profile they cannot decode rather than failing after the download begins.
Subtitle Handling
# MP4 with embedded subtitles (mov_text)
ffmpeg -i input.mp4 -i subs.srt -c copy -c:s mov_text output.mp4
# MKV with multiple subtitle tracks (-map is required, or only one subtitle is kept)
ffmpeg -i input.mp4 -i en.srt -i ko.srt -map 0 -map 1 -map 2 -c copy -c:s srt \
-metadata:s:s:0 language=eng -metadata:s:s:1 language=kor output.mkv
# WebM typically uses external WebVTT
# <track kind="subtitles" src="subs.vtt" srclang="en">
The -map options matter for the multi-track case: FFmpeg’s automatic stream selection picks at most one subtitle stream, so without them the Korean track is silently dropped. SRT files also need to be in UTF-8; a subtitle file saved in a legacy encoding (common for older Korean or Chinese subtitle files) produces an “Invalid UTF-8 in decoded subtitles text” warning and garbled characters, which -sub_charenc on the input can fix. For the web, embedded subtitle tracks in MP4 or WebM are not shown by browsers’ built-in players at all; the <track> element with an external WebVTT file is the method that works everywhere.
Common Questions
Q1. Is MKV better quality than MP4? Container does not determine quality. Same codec and bitrate are theoretically identical. Differences come from encoding settings and player decoder.
Q2. How to add subtitles to MP4? Must match track format required by platform like timed text (ttml/tx3g). Simply adding srt may not play, validation needed.
Q3. WebM on Safari? Depends on version and codec. Even in 2026, keeping MP4 fallback is safe.
Q4. “Streaming always uses MP4?”
fMP4 is common in HLS/DASH, but depending on environment, TS segments and other packaging are also used. Follow service specs.
Q5. Does remux cause loss?
-c copy moves streams as-is, no re-encoding loss. Some container metadata may change.
Conclusion
- Maximum compatibility, mobile, general distribution: MP4 is near default.
- Multiple subtitles, audio, archive: MKV is often convenient.
- Web, open codec, bandwidth: WebM can be advantageous. Files to send to people use MP4, storage & multilingual use MKV, browser & open stack consider WebM.
Decision Flowchart
Need maximum compatibility? → MP4
Need many subtitle/audio tracks? → MKV
Need web + open codecs? → WebM
Need streaming (HLS/DASH)? → fMP4 segments
Need archive with flexibility? → MKV
Related Articles
Frequently Asked Questions (FAQ)
Q. My MP4 only starts playing in the browser after it fully downloads. Is the container to blame?
A. Usually the cause is where the moov atom sits, not MP4 itself. Many encoders write the index at the end of the file, so a browser has to fetch the whole file before it can start playback. Remuxing with ffmpeg -i in.mp4 -c copy -movflags +faststart out.mp4 moves the index to the front without re-encoding, which makes progressive playback start right away.