.MKV Matroska Video
.mkv

Matroska Video

Convert MKV files to MP4, WebM, or MOV directly in your browser — no upload, no server, no quality loss on remux. FileDex uses FFmpeg WASM to remux or transcode Matroska containers locally, preserving video, audio, and subtitle tracks.

بنية الصيغة
EBML header
Segment tracks · clusters
Cluster encoded frames
ContainerEBMLOpen SourceMulti-Track2002
بواسطة FileDex

ملفاتك لا تغادر جهازك

أسئلة شائعة

How do I convert MKV to MP4 without losing quality?

Use stream copy (remux) when your MKV contains H.264 or H.265 video with AAC audio. FileDex performs this automatically — the data transfers between containers without re-encoding, so output is bit-identical to the source. If the MKV contains FLAC or DTS audio, only the audio track requires transcoding to AAC.

Why won't my MKV file play on iPhone or Apple TV?

Apple devices do not support the MKV container natively. Convert to MP4 using FileDex (stream copy if codecs are compatible) and the same video will play on iOS, iPadOS, and tvOS without quality loss.

What is the difference between MKV and MP4?

Both are containers that hold video, audio, and subtitle tracks. MKV supports virtually every codec (TrueHD, FLAC, DTS-HD, ASS subtitles) and is preferred for archival. MP4 has a restricted codec set but is accepted by all platforms, devices, and social media upload endpoints.

Can I keep subtitles when converting MKV to MP4?

Text-based subtitles (SRT) can be preserved as a separate track in MP4. ASS/SSA styled subtitles must be either burned into the video frame (hardcoded) or converted to SRT, losing formatting. FileDex can extract subtitle tracks as standalone SRT files.

Is MKV the same as WebM?

WebM is a restricted profile of the Matroska container. It uses the same EBML structure but limits codecs to VP8/VP9/AV1 video and Vorbis/Opus audio. An MKV file with VP9+Opus can be renamed to .webm and play in browsers.

ما يميز .MKV

Matroska is an open, royalty-free container format that can hold virtually any combination of video, audio, subtitle, and attachment streams in a single file. Named after the Russian matryoshka nesting dolls, the format launched in 2002 as a community-driven alternative to proprietary containers like AVI and ASF. It has since become the default output of tools like HandBrake, MKVToolNix, and most media ripping software.

اكتشف التفاصيل التقنية

EBML foundation

Matroska uses EBML (Extensible Binary Meta Language), a binary XML derivative where every element has a variable-length ID and size field — the same structural principle used by WebM, which is a restricted Matroska profile. EBML elements nest hierarchically. A Segment element contains Tracks, Clusters, Cues, Chapters, and Attachments as children. Each child has an ID encoded in 1–4 bytes (shorter IDs for common elements, longer for rare ones) and a size field using a variable-length integer scheme called VINT. This design keeps overhead low while supporting files of arbitrary length — the maximum theoretical size exceeds 16 exabytes.

The EBML header at byte zero declares the DocType (matroska or webm) and the EBML version, so parsers know immediately what they are dealing with.

Cluster-level resilience

MKV splits media data into Clusters, each starting with a timestamp. Inside each Cluster, SimpleBlock or BlockGroup elements hold individual frames with relative timestamps. Every Cluster is a self-contained parsing unit. If a Cluster is corrupted, the parser can skip to the next one by scanning for the Cluster element ID (0x1F43B675). This distributed structure means a recording interrupted by a crash typically loses only the final incomplete Cluster — seconds of footage, not the entire file.

The Cues element serves as the seek index, mapping timestamps to byte positions of Clusters. MKVToolNix writes Cues at the file's start by default, enabling instant seeking without downloading the entire file.

Track and codec flexibility

Track Type Common Codecs Notes
Video H.264, H.265, VP9, AV1 Multiple video tracks supported (e.g., 3D)
Audio AAC, FLAC, Opus, DTS, TrueHD Unlimited tracks with language tags
Subtitles SRT, SSA/ASS, PGS, VobSub Styled subtitles with fonts embedded as attachments
Attachments TTF/OTF fonts, cover art Stored in the Attachments master element

MKV carries codec-specific initialization data (CodecPrivate) that preserves decoder configuration. This matters for H.265, where the VPS/SPS/PPS parameter sets must reach the decoder before the first frame.

Chapters and editions

MKV supports a full chapter system with nested chapters, multiple named editions (e.g., theatrical cut vs. director's cut), and per-chapter language titles. An Ordered Edition can rearrange playback order, skipping or looping segments — a feature no other mainstream container offers.

File size and overhead

Container overhead for a typical 2-hour movie with one video, two audio, and three subtitle tracks is approximately 2–5 MB. The EBML encoding is compact: a Cluster header is 12 bytes, a SimpleBlock header is 4 bytes plus the frame data. For a 24 fps video, that is under 100 bytes/second of structural overhead.

When to choose MKV over MP4

Pick MKV when you need multiple audio tracks with different languages, styled ASS subtitles, embedded fonts, chapter markers, or lossless audio codecs like FLAC or TrueHD that MP4 does not officially support. For web delivery and mobile playback, MP4 remains more compatible — iOS Safari and many Android apps handle MP4 natively but need third-party players for MKV.

FileDex converts MKV to MP4, WebM, or other formats in your browser, remuxing when codecs are compatible to avoid re-encoding.

المرجع التقني

نوع MIME
video/x-matroska
Magic Bytes
1A 45 DF A3 EBML header signature shared with WebM.
المطوّر
Matroska.org
سنة التقديم
2002
معيار مفتوح
نعم — عرض المواصفات
000000001A45DFA3 .E..

EBML header signature shared with WebM.

البنية الثنائية

MKV files use EBML (Extensible Binary Meta Language), a binary XML-like format. Each element has a variable-length ID (1-4 bytes), a variable-length size descriptor, and payload data. The file opens with an EBML Header element (ID 1A 45 DF A3) declaring the EBML version and DocType ('matroska' or 'webm'). The Segment element (ID 18 53 80 67) wraps all content and contains: SeekHead (element index for fast seeking), Info (duration, timecode scale, muxing app), Tracks (codec IDs, track types, default flags), Chapters, Tags, Attachments (fonts, cover art), Cues (keyframe index for seeking), and Clusters (actual audio/video frames). Clusters contain Blocks or SimpleBlocks with track number, timecode offset, and frame data. Unlike ISOBMFF, EBML elements can be written sequentially without knowing final size (using unknown-size elements), making MKV suitable for live streaming capture.

OffsetLengthFieldExampleDescription
0x00 4 bytes EBML Header ID 1A 45 DF A3 Magic bytes identifying an EBML document. Same for MKV and WebM.
0x04 1-8 bytes EBML Header Size 01 00 00 00 00 00 00 23 VINT (variable-length integer) encoding the size of the EBML header payload.
variable variable EBMLVersion 42 86 81 01 EBML element declaring the EBML version used (typically 1).
variable variable DocType 42 82 88 6D 61 74 72 6F 73 6B 61 (matroska) String declaring the document type. 'matroska' for MKV, 'webm' for WebM.
variable 4 bytes Segment ID 18 53 80 67 Marks the start of the Segment element containing all media data and metadata.
2002Matroska project founded by Steve Lhomme as an open-source alternative to proprietary containers2003Matroska container specification v1 released; VLC and MPlayer add MKV playback support2006MKV becomes the dominant container for HD video distribution and media archival2010Google bases the WebM format on a restricted Matroska profile (VP8/VP9 + Vorbis/Opus only)2014MKV adopted as the default container in Blu-ray ripping tools (MakeMKV, HandBrake)2018IETF publishes RFC 8794 formalizing the Matroska container specification
Remux MKV to MP4 (stream copy, zero quality loss) ffmpeg
ffmpeg -i input.mkv -c copy -movflags +faststart output.mp4

-c copy performs stream copy of all tracks without re-encoding. -movflags +faststart relocates the moov atom for HTTP progressive download. Only works when MKV codecs are MP4-compatible (H.264/H.265 + AAC).

Extract subtitle track from MKV ffmpeg
ffmpeg -i input.mkv -map 0:s:0 -c:s srt output.srt

-map 0:s:0 selects the first subtitle stream. -c:s srt converts to SRT format. For ASS/SSA subtitles, use -c:s ass to preserve styling.

Convert MKV with FLAC audio to MP4 with AAC ffmpeg
ffmpeg -i input.mkv -c:v copy -c:a aac -b:a 192k -movflags +faststart output.mp4

Video stream is copied without re-encoding. FLAC audio is transcoded to AAC at 192 kbps since MP4 containers do not support FLAC. This is the minimum-loss approach when audio transcoding is required.

List all tracks in an MKV file ffprobe
ffprobe -v error -show_entries stream=index,codec_name,codec_type,channels,width,height -of csv=p=0 input.mkv

Displays track index, codec name, type (video/audio/subtitle), channel count, and resolution for each stream. Useful for identifying which tracks to map during conversion.

MKV MP4 remux lossless MP4 is required by social platforms (YouTube, Instagram, TikTok), mobile apps, and smart TVs that reject MKV uploads. When the MKV contains H.264/H.265 + AAC, stream copy transfers all data without re-encoding.
MKV MP4 transcode near-lossless MKV files containing codecs unsupported by MP4 (FLAC audio, ASS subtitles, TrueHD) require transcoding. The audio must be re-encoded to AAC and subtitles burned into the video or stripped.
MKV WEBM remux lossless WebM is a Matroska profile restricted to VP8/VP9/AV1 + Vorbis/Opus. If the MKV already contains compatible codecs, remuxing to WebM is a zero-loss container relabel enabling native browser playback in Chrome and Firefox.
MKV AVI transcode lossy Legacy hardware media players and older CCTV systems only accept AVI. Transcoding to MPEG-4 Visual + MP3 inside AVI provides compatibility with devices manufactured before 2010.
MKV GIF transcode lossy Animated GIF requires no video player dependency and embeds inline in email clients, chat apps, and Markdown renderers. Useful for creating short preview loops from MKV source footage.
متوسط

نقاط الضعف

  • Malformed EBML element with oversized VINT length field causes unbounded memory allocation in parsers that trust the declared size before reading payload data
  • Crafted Attachment element embedding executable content (e.g., .exe disguised as font file) — extracted by media servers that auto-extract attachments
  • Circular SeekHead references causing infinite parser loop and denial-of-service in streaming applications
  • Oversized Cues element with millions of index entries exhausting memory on devices with limited RAM (smart TVs, embedded players)

الحماية: FileDex processes MKV files entirely in-browser via FFmpeg WASM inside a Web Worker sandbox. No file data leaves the device. The WASM runtime operates within browser memory limits, preventing unbounded allocation from malformed EBML elements. Attachments are never extracted to disk.

VLC Media Player أداة
Cross-platform player with full MKV codec and subtitle support
FFmpeg أداة
CLI tool for MKV muxing, demuxing, and transcoding
MKVToolNix أداة
GUI and CLI tools for MKV muxing, splitting, and track management
HandBrake أداة
Open-source transcoder with MKV and MP4 output support
Plex خدمة
Media server with native MKV playback and on-the-fly transcoding
Jellyfin خدمة
Open-source media server with full MKV support and hardware transcoding
libmatroska مكتبة
Reference C++ library for reading and writing Matroska containers
Matroska Specification مواصفات
Official Matroska container specification (IETF RFC 8794)