KLV (Key Length Value) encoder and streaming decoder
A Node.js streaming parser for KLV (Key Length Value) encoded data. KLV encoding is commonly used in the motion picture industry.
var fs = require'fs'klv = require'klv';var klvStream = klvcreateStream;klvStreamon'key'console.log'Key:' + key;;klvStreamon'value'console.log'Value: ' + value;;klvStreamon'end'console.log'All done';;var fileStream = fscreateReadStream'some_klv_file';fileStreampipeklvStream;
Incoming streams can have multiple KLVs; the parser will emit events as it encounters each one.
Data can be encoded into a KLV; just supply the key and value as buffers and use:
var klv = require'klv';var myKLV = klvencodeKLVmyKeyBuffer myValueBuffer;
An optional BER length can be provided as a final parameter if you want to explicitly set the length in bytes:
klvencodeKLVmyKeyBuffer myValueBuffer 4;
Copyright 2013 Arts Alliance Media
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.