The basics
What is an MKV file?
MKV is the file extension of Matroska, an open, royalty-free container format. Its strength is that it holds almost anything: any common video and audio codec, as many audio tracks and subtitle tracks as you like, each labelled with its language, plus chapters, tags and attached files such as cover art and fonts. That's why films and TV episodes ripped from Blu-ray and DVD, anime with styled subtitles, and many screen recordings come as MKV.
Like MP4, MKV is a container: the compression is done by codecs such as H.264, HEVC or AV1 inside it. The container decides what can travel together and how players find it; the codecs decide what device can decode it. A file named .mkv tells you a lot about its features, and nothing about its codecs.
Matroska started in 2002 as a community project and was published as an IETF standard, RFC 9559, in October 2024. WebM, the web video format, is a restricted version of it.
Anatomy
What's inside an MKV file
Matroska is written in EBML, a binary format where every element is an ID, a size and the data, and elements nest like the dolls the format is named after. IDs and sizes are variable-length numbers, so small values take a single byte. Here is the element tree of sample-multitrack.mkv, our 10-second sample with five tracks, chapters and an attachment, as read from the file. Offsets are in bytes.
offset element ID bytes content
0 EBML header 1A 45 DF A3 35 bytes
21 DocType 42 82 "matroska"
32 DocTypeVersion 42 87 4
40 Segment 18 53 80 67 1,289,511 bytes
52 SeekHead 11 4D 9B 74 where the other elements are
57 CRC-32 BF checksum of the SeekHead
153 Void EC 51 bytes kept free
213 Info 15 49 A9 66 title, duration 10,021 ms
356 Tracks 16 54 AE 6B
368 TrackEntry 1 V_MPEG4/ISO/AVC 1280×720
522 TrackEntry 2 A_AAC eng "English · AAC stereo"
640 TrackEntry 3 A_OPUS nld FlagDefault 0
780 TrackEntry 4 S_TEXT/UTF8 eng subtitles
843 TrackEntry 5 S_TEXT/UTF8 nld FlagDefault 0
912 Chapters 10 43 A7 70 1 edition: Start, Middle, End
1,035 Attachments 19 41 A4 69
1,047 AttachedFile 61 A7 cover.png, image/png, 7,420 bytes
8,510 Tags 12 54 C3 67 artist, comment, per-track tags
9,129 Cluster 1F 43 B6 75 starts at 0 s
9,142 Timestamp E7 0
9,145 SimpleBlock A3 track 1: H.264 keyframe, 20,356 bytes
… video, both audio tracks and subtitles
242,501 Cluster starts at 1.941 s
517,124 Cluster starts at 3.946 s
765,846 Cluster starts at 5.952 s
1,037,908 Cluster starts at 7.936 s
1,289,332 Cues 1C 53 BB 6B seek index: 7 cue points- 1
1A 45 DF A3The EBML header
The first four bytes of every Matroska and WebM file. The header declares the EBML version and the document type.
- 2
DocType "matroska"The document type
matroskahere; a WebM file sayswebm. DocTypeVersion 4 means the file may use elements added in Matroska version 4, the current one. - 3
SegmentThe Segment
One element that contains everything else. Inside it, the top-level elements can come in almost any order; the SeekHead says where to find them.
- 4
CRC-32Checksums
FFmpeg puts a CRC-32 element first in each top-level element, so a player or archive tool can detect damaged data. They're optional; WebM leaves them out.
- 5
Tracks / TrackEntryFive tracks
Each track has a number, a type, a codec ID, a language and an optional name.
FlagDefault 0marks a track that shouldn't be picked automatically; tracks without it default to on. This is how a player knows to start with English sound and English subtitles, and what to list in its track menus. - 6
ChaptersChapters
Named start and end times that players show as a chapter menu or skip buttons. An edition can also define an alternative order, used for things like a director's cut.
- 7
AttachmentsAttached files
Any file can be stored inside, with a name and media type: cover art, as here, or fonts that styled ASS subtitles need. Players use the ones they understand and ignore the rest.
- 8
TagsMetadata
Name and value pairs for the whole file or for single tracks, chapters or attachments: title, artist, comment, encoder settings, and the like.
- 9
Cluster / SimpleBlockThe media
Clusters of about two seconds each, holding the frames of all five tracks, interleaved by time. Each block names its track, its time offset from the Cluster's timestamp, and whether it's a keyframe. Subtitles are stored as blocks with a duration.
- 10
CuesThe seek index
Where the keyframes are, so a player can jump to any point. Like MP4's index, it's written at the end; unlike MP4, a file without it still plays from the start, it just seeks slowly.
Features
Multiple tracks, subtitles, chapters and attachments
| Feature | What it does | Typical use |
|---|---|---|
| Several audio tracks | Each with a language, a name and default and forced flags | Original language plus dubs, director's commentary, stereo and surround mixes |
| Subtitle tracks | Text (S_TEXT/UTF8 for SRT, S_TEXT/ASS for styled ASS) or images (S_HDMV/PGS from Blu-ray, S_VOBSUB from DVD) | Several languages; "forced" tracks for foreign-language scenes only |
| Chapters | Named points in time, optionally nested, in one or more editions | Chapter menus and skip buttons, as on a disc |
| Attachments | Any file, stored inside the MKV with a name and media type | Fonts for ASS subtitles, cover art |
| Tags | Name and value pairs at file, track or chapter level | Title, artist, encoder settings |
| Lossless codecs | FFV1 video, FLAC or PCM audio | Archiving and preservation |
Our sample-multitrack.mkv uses most of these: an H.264 video track, English AAC audio and a Dutch Opus track with a different pitch (so you can hear the switch), English and Dutch subtitles, three chapters and an attached cover image. In VLC, look under Audio → Audio Track, Subtitle → Sub Track and Playback → Chapter.
Default and forced flags
Which track plays first is up to the player, guided by flags in the file and your language settings. If the wrong language plays by default, you can change the flags without re-encoding: mkvpropedit film.mkv --edit track:a1 --set flag-default=0 --edit track:a2 --set flag-default=1 (from MKVToolNix).
Under the hood
EBML: why Matroska is so flexible
Every piece of an MKV file is an EBML element with a numeric ID. A player that meets an ID it doesn't know reads its size and skips it, so new features can be added without breaking old players. Several design choices follow from that:
- Unknown sizes. A Segment or Cluster can say "size unknown" and simply continue until the next element begins. That lets a recorder or a live stream write a file without knowing how long it will be.
- Recordings survive crashes. Because every Cluster can be read on its own, an MKV whose recording was cut off still plays up to the last complete Cluster. That's why OBS Studio has long recommended recording to MKV: a crash or a full disk ruins a plain MP4, whose index is written last.
- Void elements reserve space, so tools can later add or grow metadata, such as the index or tags, without rewriting the whole file.
- CRC-32 elements can protect each top-level element, which archives value.
Related formats
MKV vs MP4, WebM and AVI
| MKV | MP4 | WebM | AVI | |
|---|---|---|---|---|
| Codecs | Almost any | H.264, HEVC, AV1, AAC and a few more | VP8, VP9, AV1, Vorbis, Opus only | Many, mostly old |
| Subtitle tracks | Many, text or image | Limited (mov_text) | WebVTT | No standard |
| Chapters | Yes | Yes | Limited | No |
| Attachments | Yes | Cover art only | No | No |
| Safe if recording is cut off | Yes, up to the cut | No, unless fragmented | Yes | Partly, no index |
| Browsers | Chrome, Edge, Firefox | All | All | None |
| Phones and TVs | Varies | All | Varies | Varies |
Moving streams from MKV to MP4 without re-encoding (remuxing) works when the codecs are allowed in MP4: ffmpeg -i in.mkv -map 0 -c copy -c:s mov_text out.mp4. Text subtitles become MP4's simpler mov_text and lose ASS styling; image subtitles (PGS, VobSub) can't go into MP4 at all and have to be dropped or burned in.
On the web
Does MKV play in a browser?
More often than it used to. Chrome and Edge play MKV files that use web codecs (H.264, VP9 or AV1 video with AAC, Opus or Vorbis audio), even though Chromium long treated this as an unofficial extra. Firefox added official Matroska support in version 145, in November 2025, for AVC, HEVC, VP8, VP9, AV1, AAC, Opus and Vorbis. Safari doesn't play MKV.
- Even where the video plays, browsers generally don't offer MKV's extras: subtitle tracks inside the file aren't shown, only one audio track is played, and chapters are ignored.
- Audio in AC-3, E-AC-3, DTS or TrueHD, common in films ripped from discs, often doesn't decode, so the video plays silently.
- For a page that must work everywhere, publish an MP4 with H.264 and AAC, and put subtitles in a separate WebVTT (
.vtt) file.
Troubleshooting
Why won't my MKV play properly? Common problems and fixes
| Symptom | Usual cause | Fix |
|---|---|---|
| Picture but no sound | Surround audio (DTS, TrueHD, AC-3) the device or browser can't decode. | Convert just the audio: ffmpeg -i in.mkv -map 0 -c copy -c:a aac out.mkv. |
| Subtitles don't show | The player doesn't support that subtitle type, or the track isn't enabled. | Pick it from the player's subtitle menu, or extract it: ffmpeg -i in.mkv -map 0:s:0 subs.srt. |
| Subtitles in the wrong font or position | Styled ASS subtitles whose attached fonts the player ignores. | Use VLC or mpv, which load attached fonts. |
| Wrong language plays first | The default flags point at another track. | Change the flags with mkvpropedit or MKVToolNix GUI; no re-encoding needed. |
| Video editor won't import it | Many editors, including iMovie and Final Cut Pro, don't read MKV. | Remux to MP4 or MOV with -c copy first. |
| TV or phone refuses it | An unsupported codec (often HEVC 10-bit or AV1) or audio format. | Use a player app such as VLC, Plex or Kodi, or re-encode to H.264 + AAC. |
How to
How to open, edit and convert an MKV file
- Windows: the Media Player app plays MKV with common codecs; VLC and mpv play nearly everything, including all track types.
- macOS: QuickTime Player doesn't open MKV. Use VLC or IINA.
- Linux: VLC or mpv.
- Phones and TVs: VLC on Android and iPhone; Plex, Kodi and Jellyfin on TVs and streaming boxes.
- Add, remove or relabel tracks: MKVToolNix (free, Windows, macOS, Linux) does all of this without re-encoding.
mkvinfoshows the element tree. - Convert: remux with FFmpeg when the codecs fit (see above), or re-encode with HandBrake, which reads MKV and writes MKV or MP4.
Long term
MKV for archiving, and is it safe?
Because it's open, documented and checksummed, Matroska with the lossless FFV1 video codec (standardised as RFC 9043) has become a common choice for digital preservation: the Library of Congress lists FFV1 in Matroska as a preferred format for video, and several national and university archives use it. Our sample-ffv1-flac.mkv is a small example.
As for safety, an MKV can't run code by itself, but two things are worth knowing:
- Attachments can be any file. The specification warns that an attachment could be a program. Players don't run attachments, but tools that extract them could hand you one, so treat extracted files like any download.
- Decoder and subtitle bugs. MKVs carry many codecs and styled subtitles, and a crafted file could exploit a flaw in any of them. Keep VLC, mpv and other players updated.
Free downloads
Sample MKV files to download
Free sample MKV files for testing players, browsers, track handling and transcoding pipelines. All are made from FFmpeg test patterns and generated tones, with the format written on screen. Each was checked with ffprobe and fully decoded without errors.
What's inside sample-multitrack.mkv
A 10-second, 1280×720 MKV at 30 fps with five tracks, three chapters and an attachment. In a browser you'll see the video with the default audio; open it in VLC or mpv to try the rest.
Video
H.264 High profile with the frame counter, the label band and a white square that flashes on every whole second, in step with a beep in both audio tracks.
Audio track 1 (English, default)
AAC stereo: 440 Hz on the left channel, 660 Hz on the right, plus the 1 kHz beep.
Audio track 2 (Dutch)
Opus mono at 880 Hz with the same beep. Switching to it changes the pitch, so you can hear that the switch worked.
Subtitles
Two SRT tracks, English (default) and Dutch, with three cues each that name the current chapter.
Chapters
Start (0 s), Middle (4 s) and End (7 s). Players show them as a chapter menu or skip buttons.
Attachment
cover.png, a 320×180 cover image. Some players and media managers show it as cover art;ffprobelists it as an attachment.Metadata
Title, artist and a comment naming this page, and a name and language on every track.
ffprobeormkvinfoshows them.
All sample MKV files
Multiple tracks, subtitles, chapters
sample-multitrack.mkv · 1.2 MB (1,289,563 bytes)
10 seconds at 1280×720, 30 fps: H.264 video, English AAC stereo and Dutch Opus mono audio, English and Dutch SRT subtitles, 3 chapters and an attached cover image.
- Testing audio and subtitle track switching
- Checking what survives a conversion or an upload
HEVC + FLAC
sample-hevc-flac.mkv · 233.7 KB (239,330 bytes)
4 seconds at 640×360, HEVC Main profile with lossless FLAC stereo audio, a combination common in MKV files and rare in MP4.
- Testing HEVC and FLAC support in players and browsers
- Checking transcoders handle lossless audio
FFV1 + FLAC (lossless, archival)
sample-ffv1-flac.mkv · 424.3 KB (434,503 bytes)
2 seconds at 320×240, 25 fps: SMPTE colour bars in FFV1 version 3 with slice checksums, every frame a keyframe, plus FLAC audio. Fully lossless. Browsers can't decode FFV1.
- Testing preservation and archive workflows
- Checking that a pipeline detects a codec it can't preview
100 KB MKV file
sample-100kb.mkv · 100 KB (102,400 bytes)
3 seconds at 320×180, H.264 + AAC, padded with an EBML Void element to exactly 102,400 bytes. Players skip the padding.
- Upload and size-limit tests
- Checking that parsers skip Void elements
Ways to test with them
- Track switching: play
sample-multitrack.mkvand switch audio tracks: the tone should jump from 440/660 Hz to 880 Hz. Turn subtitles on and off and switch language. - Browser support: open the featured file in Chrome, Edge, Firefox and Safari. Expect video with English audio in the first three, no subtitles, and nothing in Safari.
- Conversions: convert the featured file to MP4 with your tool and check which tracks, chapters and subtitles survive.
- Unplayable input:
sample-ffv1-flac.mkvis valid but won't preview in a browser; use it to test thumbnails and error messages. - Size limits:
sample-100kb.mkvis exactly 102,400 bytes, so you can test a limit at the boundary.
Free to use for testing, teaching and demos, commercially or not, with no attribution needed. A link back to this page is always appreciated.
Put it online
Have an MKV file? Give it a link.
Drop an MKV on 99helpers and it gets its own address to send instead of a large attachment. Chrome, Edge and Firefox play MKVs with common web codecs straight from the link; other visitors can download it and open it in VLC.
Questions
MKV files, frequently asked
What is an MKV file?
A video file in the Matroska format, an open container that can hold video, several audio and subtitle tracks, chapters and attached files in one file.
Is MKV better than MP4?
It holds more: any codec, many audio and subtitle tracks, attachments. MP4 plays on more devices, apps and browsers. Use MKV for archiving and films with several languages, MP4 for sharing.
How do I convert MKV to MP4?
If the codecs are H.264, HEVC or AV1 with AAC, remux it without re-encoding: ffmpeg -i in.mkv -map 0 -c copy -c:s mov_text out.mp4. Otherwise re-encode with HandBrake.
Can I play MKV files in a browser?
Chrome and Edge play MKVs with common web codecs, and Firefox has done so officially since version 145. Safari doesn't. Browsers generally ignore the subtitle tracks and play only one audio track.
Why does my MKV have no sound?
The audio is probably DTS, TrueHD or AC-3, which many devices and browsers can't decode. Play it in VLC, or convert just the audio to AAC.
How do I change the audio or subtitle language in an MKV?
Use your player's track menus. To change which track plays by default, edit the flags with MKVToolNix or mkvpropedit, without re-encoding.
What does MKV stand for?
Matroska Video. The name comes from matryoshka, the Russian nesting doll. Audio-only Matroska files use .mka.
Is an MKV file safe?
It can't run code, but it can contain attached files of any type, and crafted files could exploit player bugs. Keep your player updated and treat extracted attachments like downloads.
Related formats
Other file types explained
Keep going
Related
Sources
- RFC 9559: Matroska Media Container Format Specification
- RFC 8794: Extensible Binary Meta Language (EBML)
- Library of Congress: Matroska Multimedia Container
- MDN: Firefox 145 release notes (Matroska support)
- Matroska project
Last reviewed 27 October 2026.