https://github.com/t1st3/is-mkv
Check if a Buffer/Uint8Array is a MKV video
https://github.com/t1st3/is-mkv
buffer detect file javascript magic-numbers mkv uint8array
Last synced: about 1 month ago
JSON representation
Check if a Buffer/Uint8Array is a MKV video
- Host: GitHub
- URL: https://github.com/t1st3/is-mkv
- Owner: t1st3
- License: mit
- Created: 2016-01-19T23:54:45.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-06-03T09:18:46.000Z (almost 5 years ago)
- Last Synced: 2025-03-14T06:46:46.412Z (2 months ago)
- Topics: buffer, detect, file, javascript, magic-numbers, mkv, uint8array
- Language: JavaScript
- Size: 1.05 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# is-mkv
[](https://www.npmjs.com/package/is-mkv)
[](https://travis-ci.org/t1st3/is-mkv)> Check if a Buffer/Uint8Array is a [MKV](https://en.wikipedia.org/wiki/Matroska) video
## Install
```sh
$ npm install --save is-mkv
```## Usage
### Node.js
```js
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
```### Browser
```js
var xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.mkv');
xhr.responseType = 'arraybuffer';xhr.onload = function () {
isMkv(new Uint8Array(this.response));
//=> true
};xhr.send();
```## API
### isMkv(buffer)
Accepts a Buffer (Node.js) or Uint8Array.
It only needs the first 39 bytes.
## License
MIT © [t1st3](https://t1st3.com)