About Matroska video files
A flexible container that can hold almost any codec, plus multiple audio and subtitle tracks. WebM is a restricted subset of Matroska. RFC 9559 (2024) registered video/matroska, but most servers still send video/x-matroska. Browsers don’t officially support .mkv, though Chrome plays some files whose codecs it knows; remux or transcode to MP4 or WebM for the web.
Other types seen for these files:
video/matroska
,
audio/matroska
,
audio/x-matroska
. Accept them when reading uploads, but send video/x-matroska yourself.
File signature
MKV files start with 1A 45 DF A3 (EBML header, shared with WebM). The extension and the type a browser reports for an upload both
come from the file name, so check these bytes on the server before trusting a file.
Serve .mkv with the right Content-Type
Content-Type: video/x-matroska
video/x-matroska mkv mka;
AddType video/x-matroska .mkv .mka
@mkv path *.mkv *.mka
header @mkv Content-Type "video/x-matroska"
curl -sI https://example.com/file.mkv | grep -i '^content-type'
# Content-Type: video/x-matroska
Set the type in code
res.set('Content-Type', 'video/x-matroska');
// Or make the browser download it:
res.attachment('file.mkv');
import mimetypes
mimetypes.add_type('video/x-matroska', '.mkv') # if your system doesn't know it
mimetypes.guess_type('file.mkv')[0] # 'video/x-matroska'
mime.AddExtensionType(".mkv", "video/x-matroska")
w.Header().Set("Content-Type", "video/x-matroska")
Accept .mkv uploads
<input type="file" accept=".mkv,.mka,video/x-matroska">
The accept attribute only filters the file picker; users can still choose another file. Listing the
extension as well as the type matters, because operating systems don’t always report the type you expect.
Related types
More video
.mov , .m3u8 , .ts . Look up any extension or type with the MIME type lookup.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What is the MIME type for .mkv files?
video/x-matroska. You may also see video/matroska, audio/matroska, audio/x-matroska, which are older or unofficial; send video/x-matroska. The full header is "Content-Type: video/x-matroska".
Why does my server send the wrong Content-Type for .mkv?
Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .mkv is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".
How can I check that a file really is MKV?
Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. MKV files start with 1A 45 DF A3 (EBML header, shared with WebM). The MIME type lookup on this site reads them for you when you drop a file on it.