MKV
video/x-matroska
Magic Bytes
Offset: 0
1A 45 DF A3 93 42 82 88 6D 61 74 72 6F 73 6B 61
The Matroska Video (MKV) format is an open standard multimedia container maintained by the Matroska Association, derived from Extensible Binary Meta Language. It is primarily used for storing high-definition video content, capable of holding an unlimited number of video, audio, and subtitle tracks within a single file. As a royalty-free standard, it functions as a flexible envelope for various codecs and is widely supported by cross-platform media players and modern hardware devices.
Validation Code
How to validate .mkv files in Python
Python
def is_mkv(file_path: str) -> bool:
"""Check if file is a valid MKV by magic bytes."""
signature = bytes([0x1A, 0x45, 0xDF, 0xA3, 0x93, 0x42, 0x82, 0x88, 0x6D, 0x61, 0x74, 0x72, 0x6F, 0x73, 0x6B, 0x61])
with open(file_path, "rb") as f:
return f.read(16) == signature
How to validate .mkv files in Node.js
Node.js
function isMKV(buffer: Buffer): boolean {
const signature = Buffer.from([0x1A, 0x45, 0xDF, 0xA3, 0x93, 0x42, 0x82, 0x88, 0x6D, 0x61, 0x74, 0x72, 0x6F, 0x73, 0x6B, 0x61]);
return buffer.subarray(0, 16).equals(signature);
}
Go
func IsMKV(data []byte) bool {
signature := []byte{0x1A, 0x45, 0xDF, 0xA3, 0x93, 0x42, 0x82, 0x88, 0x6D, 0x61, 0x74, 0x72, 0x6F, 0x73, 0x6B, 0x61}
if len(data) < 16 {
return false
}
return bytes.Equal(data[:16], signature)
}
API Endpoint
GET
/api/v1/mkv
curl https://filesignature.org/api/v1/mkv