Check if a Buffer/Uint8Array is a MKV video
$ npm install --save is-mkv
var readChunk = require('read-chunk'); // npm install read-chunk
var isMkv = require('is-mkv');
var buffer = readChunk.sync('unicorn.mkv', 0, 39);
isMkv(buffer);
//=> true
var xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.mkv');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
isMkv(new Uint8Array(this.response));
//=> true
};
xhr.send();
Accepts a Buffer (Node.js) or Uint8Array.
It only needs the first 39 bytes.
MIT © t1st3