MKV Format: How It Works and How It Compares to MP4

mkv to mp4

What Is MKV Format (Matroska Video File)?

Matroska Multimedia Container is a free and open container video format that allows you to store an unlimited number of video, audio, image or subtitle tracks in a single file.

MKV is a universal format for storing multimedia content such as movies and TV shows. Although it is similar to other containers such as AVI, MP4, and Advanced Systems Format (ASF), its specifications are fully open and its implementation consists mostly of open source software.

MKV is supported by a non-profit organization called Association Loi 1901. It is a royalty-free standard provided under the GNU L-GPL license. MKV analysis and playback libraries are provided under the BSD license for commercial enterprise use.

The Matroska file extension is .mkv for video (which may also contain subtitles or audio), .mk3d for stereoscopic video, .mka for audio-only files, and .mka for subtitles only.

In this article:

MKV Format: History and Goals

Launched in December 2002, the Matroska project split from the Multimedia Container Format (MCF) after a disagreement between Steve Lhomme and Lasse Kärkkäinen, the lead developer of MCF, regarding the use of Extensible Binary Meta Language (EBML). Lhomme founded Matroska and many developers moved to the new project in response to the MCF lead developer’s break from coding.

The developers of Matroska emphasized the advantages of using EBML rather than a different binary format. These include making the format more future-proof and easier to extend to accommodate changing goals and new developments. The MKV format’s design considers extensibility and longevity, unlike other formats like AVI.

Matroska team members have openly discussed the project’s long-term goals on and The project aims to create a modern, extensible, flexible container format that works across multimedia platforms. It also seeks to provide strong streaming support, specialized file creation and editing tools, development support libraries to extend Matroska support to applications, and EBML-based menus.

The Matroska team collaborates with third-party hardware manufacturers to embed Matroska support in various multimedia devices. The project also encourages operating systems to offer native support for Matroska.


Why is MKV called Matroska?

MKV is called Matroska as an analogy to the traditional Russian matryoshka dolls. Similar to these dolls which contain smaller ones inside, a Matroska file can hold many different media types (like audio, video, and subtitles) within one file. Just as the nested doll opens to reveal multiple other dolls, the Matroska container can hold multiple media elements.

MKV File Format Technical Deep Dive

Matroska introduces several constraints to the EBML header’s specification:

  • The document type (docType) must be Matroska.
  • The maximum ID length (EBMLMaxIDLength) is 4.
  • The maximum size (EBMLMaxSizeLength) must be from 1 to 8.

The top-level elements must all be coded in four octets, according to the following principles:

  • Language codes – versions 1-3 of Matroska use language codes with the three bibliographic ISO-639-2 form letters (i.e., “eng” for English) and an optional country code (i.e., “eng-ca” for Canadian English). From version 4 and up, Matroska supports both ISO 639-2 and BCP 47 MAY for language codes, although the latter is the recommended option.
  • Physical types – these mean different things for video and audio files. For instance, a ChapterPhysicalEquiv of 60 means DVD, VHS, and laserdisc for video. However, it means CD (12, 10, and 7 inches), tape, minidisc, and DAT for audio.
  • Block structure—the block header includes information about the type of lacing, timestamps, track number, etc.
  • Lacing – this mechanism saves space when storing the data for small data use cases like individual frames.
  • Simple block structure – based on the block structure, this structure adds “discardable” and “keyframe” flags.

Matroska documents must comprise at least one EBML document of the Matroska document type. Every EBML document starts with an EBML header, followed by an EBML root element defined as a segment – various top-level elements can occur within a segment.

EBML involves a system of “elements” for composing a document. Matroska defines the following as top-level elements in a Matroska file:

  • EBML document – the file’s wrapper.
  • EBML header – contains the file’s header information, such as the document type, etc.
  • Segment – the top element containing the rest of the top-level elements.
  • Seek head – defines the position of the segments of different top-level elements.
  • Info – provides general information about the segment.
  • Tracks – an information element describing various tracks.
  • Chapters – an element defining basic menu and partition information.
  • Cluster – contains the block structure.
  • Cues – an element containing all the segment’s local entries.
  • Attachments – an element containing any attached files.
  • Tags – an element containing metadata to describe tracks, editions, chapters, attachments, or the overall segment.

mkv to mp4

MKV vs. MP4: 4 Key Differences

What is MP4 Format

What is an MP4 video file? MP4 stands for MPEG-4 Video file. Developed by the Moving Pictures Experts Group (MPEG) and released in 2001, it’s a compressed file format that can contain video, audio, subtitles, and still images. MP4s are one of the most common video file formats used for downloading and streaming videos from the internet. They use the MPEG-4 encoding algorithm to store video and audio files and text, offering lower definition than some other formats.

MP4 in Everyday Use 

MP4 format video  is popular for storing videos on devices, including smartphones, tablets, and digital cameras. These devices are commonly used for recording and viewing MP4 files. MP4 files are typically encountered when downloading a video from the internet or using a DVD ripping program. You can determine if your video is in MP4 format video by right-clicking on the video on your computer and selecting ‘Properties’. The easiest way to play an MP4 file is to double-click on it.

1. Video Quality

Both MKV and MP4 container formats can provide high-quality video playback. The video quality itself is not determined by the container format but rather by the video codec used to compress the video data.

Both formats support a wide range of codecs, including popular ones like H.264 and H.265 (HEVC). Therefore, video quality is mostly dependent on the codec used and the compression settings, rather than the container format itself.

2. File Size

File size is also influenced by the codec used and the compression settings. However, MKV is known to support lossless video compression, which can result in larger file sizes but better video quality preservation.

MP4, on the other hand, is more commonly associated with efficient compression that leads to smaller file sizes, making it more suitable for streaming and sharing on the internet. In general, the file size will depend on the codec and compression settings chosen for a particular video, rather than the container format itself. MP4 files are typically less than 100 MB when using the h.264 codec, while MKV is known to support lossless video compression, which can result in larger file sizes but better video quality preservation.

When thinking “what is mp4 video”, it’s important to note that MP4 files, due to their high compression, typically result in smaller file sizes compared to MKV. This makes MP4 particularly suitable for streaming and sharing on the internet. The high compression also contributes to MP4’s popularity as a standard video format on the web.

3. Video and Audio Codecs Supported

MKV is an open standard format, which means it supports a wide variety of video and audio codecs, including popular ones like H.264, H.265, VP9, and AV1 for video, and MP3, AAC, AC3, DTS, and FLAC for audio. The flexibility of MKV allows it to store multiple video, audio, and subtitle tracks in a single file, making it a popular choice for high-quality video playback and media storage.

MP4 is based on the MPEG-4 standard and supports a more limited set of video and audio codecs compared to MKV. For video, it primarily supports codecs like H.264, H.265, and MPEG-4 Part 2. For audio, it supports codecs such as AAC, MP3, and Apple Lossless Audio Codec (ALAC). While MP4’s codec support is more limited than MKV’s, it still covers the most commonly used codecs, making it a practical choice for most users.

4. Compatibility

MP4 enjoys more extensive compatibility across various devices and platforms, such as smartphones, tablets, gaming consoles, and smart TVs. Additionally, MP4 format videos can store extensive metadata, such as title, author, and copyright information, which aids in organizing and categorizing content. Its wide acceptance is due to its efficient compression and the fact that it is an international standard. MP4 is also the preferred format for video sharing platforms like YouTube and Vimeo, as well as for streaming services.

MKV, while being an open standard and supporting more codecs, has slightly less compatibility with devices and platforms compared to MP4. Although many media players and software support MKV playback, there may still be instances where compatibility issues arise, especially with older devices or systems. However, the gap in compatibility is continually narrowing as more devices and platforms adopt support for the MKV format.

Pros and Cons of MKV and MP4

MKV Pros and Cons

Pros of MKV:

  • Versatility: MKV supports a wide range of codecs, making it compatible with various media players and devices.
  • Multiple streams: It can contain multiple video, audio, and subtitle tracks in a single file, making it convenient for users who prefer different languages or subtitle options.
  • Chapter support: The format supports chapter points, allowing users to easily navigate through the video file.
  • Open-source: MKV is an open-source project, which means its development is driven by the community, ensuring continuous improvements and updates.
  • Error recovery: The format is more resistant to corruption, and in case of file errors, it is usually easier to recover the playable content.

Cons of MKV:

  • Compatibility: Despite its versatility, MKV is not universally supported by all devices and media players, which can sometimes require additional software or conversion.
  • File size: High-quality video and audio in MKV files can result in larger file sizes compared to other formats like MP4 or AVI.
  • Limited metadata support: MKV does not support extensive metadata as some other formats, which can make it less desirable for certain applications.
  • Encoding and decoding: Some video editing software may not support MKV, requiring conversion before editing. Additionally, hardware acceleration for encoding and decoding MKV files may not be as widely supported as other formats.
  • Lack of DRM support: MKV does not support digital rights management (DRM) natively, which may limit its use for distributing copyrighted or protected content.

MP4 Pros and Cons

Pros of MP4:

  • Compatibility: MP4 is widely supported by various devices, operating systems, and media players, making it a popular choice for video sharing and streaming.
  • Compression: The format uses advanced video and audio codecs, such as H.264 and AAC, which provide good quality at relatively smaller file sizes.
  • Streaming: MP4 supports progressive playback and adaptive streaming, allowing users to watch videos while they’re being downloaded or adapt to different bandwidths in real-time.
  • Metadata support: MP4 files can store extensive metadata, including title, author, and copyright information, which can be useful for organizing and categorizing content.
  • DRM support: MP4 natively supports digital rights management (DRM), making it suitable for distributing copyrighted or protected content.

Cons of MP4:

  • Limited codec support: MP4 supports a more limited range of codecs compared to other container formats like MKV, which can restrict its use in certain scenarios.
  • Single subtitle track: MP4 typically supports only one embedded subtitle track, which might be inconvenient for users who prefer multiple language options.
  • Less error recovery: MP4 files are more prone to corruption compared to formats like MKV, and recovery of corrupted files can be more challenging.
  • Lossy compression: Although MP4 offers good quality at smaller file sizes, its compression is lossy, which means some data is discarded during encoding, potentially resulting in lower quality compared to lossless formats.

Pros of MP4 include its high compression and quality, making it flexible for various uses. However, a notable disadvantage is the intensive ability required for encoding and decoding, which might be a consideration for users with limited processing power.

Automated Video Format Conversion With Cloudinary

Cloudinary offers a versatile, effective, and efficient solution for managing media, replete with dynamic, automated optimization and delivery features. For example, setting the fetch_format parameter to auto (f_auto in URLs) causes Cloudinary to automatically select the format and codec based on the requesting browser. Chrome users would most likely receive a VP9-encoded WebM file; Safari users, an HEVC-encoded MP4 file. If a browser does not support either of those formats, Cloudinary delivers the video as an H.264-encoded MP4 file, which works in almost all browsers.

Interested? Have a try for free by first signing up for a free Cloudinary account.

Last updated: May 1, 2024