is-opus
Check if a Buffer/Uint8Array is an OPUS audio file.
Install
$ npm install --save is-opus
Usage
Node.js
var readChunk = require('read-chunk'); // npm install read-chunk
var isOpus = require('is-opus');
var buffer = readChunk.sync('unicorn.opus', 0, 36);
isOpus(buffer);
//=> true
Browser
var xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.opus');
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
isOpus(new Uint8Array(this.response));
//=> true
};
xhr.send();
API
isOpus(buffer)
Accepts a Buffer (Node.js) or Uint8Array.
It only needs the first 36 bytes.
License
MIT © t1st3