Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@vidterra/misb.js
Advanced tools
Lightweight JavaScript library for parsing and manipulating MISB KLV metadata
Lightweight JavaScript library for parsing and manipulating MISB KLV metadata
misb.js is a dependency free library to parse and create KLV metadata in JavaScript. It supports both front-end web browsers and back-end Node.js implementations. misb.js is not affiliated with or endorsed by the Motion Imagery Standards Board.
To install misb.js
with npm run
npm install @vidterra/misb.js
misb.js
currently requires the use of Node.js 14.x LTS and higher
Not started
const { st0601 } = require('@vidterra/misb.js')
const klv =[
'060E2B34020B01010E0103010100000081D2020800046050584E0180030A4D697373696F6E20',
'3132050271C20602FD3D070208B80A085072656461746F720B07454F204E6F73650C0E47656F',
'64657469632057475338340D045595B66D0E045B5360C40F02C2211002CD9C1102D917120472',
'4A0A20130487F84B86140400000000150403830926160212811704F101A229180414BC082B19',
'0234F3301C01010102010703052F2F5553410C01070D060055005300411602000A4101065E22',
'0170F592F02373364AF8AA9162C00F2EB2DA16B74341000841A0BE365B5AB96A36450102AA43'
]
const json = st0601.parse(klv.join(''), { debug: true })
console.log(json)
See scripts/file.js
for an example of programmatically reading KLV from a MPEG-TS transport file. The conceptual workflow looks like:
ffmpeg -i <input filename> -map 0:d:0 -codec copy -f data <output filename>
See scripts/stdin.js
for an example of programmatically reading KLV from a ffmpeg pipe
ffmpeg -i <input filename> -map 0:d:0 -codec copy -f data - | node stdin.js
The exported misb.js
object contains the following modules:
const misb = require('misb.js') // export all modules
const { st0601, st0102, st0903, klv } = require('misb.js') // export the modules you want to use
st0601.key
Returns a 16 byte Buffer
with the ST0601 key
st0601.parse(buffer, options)
Returns a JSON object of parsed metadata
A string or Node.js Buffer
that starts with a fully formed packet of ST 0601 KLV. Embedded KLV within ST 0601, such as ST 0102, will also be parsed.
Invalid KLV will cause an exception to be thrown. The KLV may have extra trailing content after the complete KLV packet, it will be ignored.
An object with additional options.
false
): print parsed metadata to standard outputst0102.parse(buffer, options)
Returns a JSON object of parsed metadata
A string or Node.js Buffer
that only contains valid ST 0102 KLV content. Invalid KLV will cause an exception to be thrown. Any additional content other than ST 0102 KLV will cause an exception to be thrown.
An object with additional options.
false
): print parsed metadata to standard outputst0903.key
Returns a 16 byte Buffer
with the ST0903 key
st0903.parse(buffer, options)
Returns a JSON object of parsed metadata
A string or Node.js Buffer
that starts with a fully formed packet of ST 0903 KLV.
Invalid KLV will cause an exception to be thrown. The KLV may have extra trailing content after the complete KLV packet, it will be ignored.
An object with additional options.
false
): print parsed metadata to standard outputklv.getBer(buffer)
Parses the BER for long-form or short-form encoding.
A short-form encoded BER will return { berHeader: 0, berLength: 1, contentLength: <length of KLV content> }
A long-form encoded BER will return { berHeader: 1, berLength: <length of BER in addition to header>, contentLength: null }
. This requires further parsing using the getContentLength
function.
A Buffer
with a single byte. Any additional content than the single byte of BER header will cause an exception to be thrown.
klv.getContentLength(buffer)
Parses the content length of a long-form BER.
A Buffer
of bytes that sum to the length of the KLV content. Pass the number of bytes returned by klv.getBer(buffer).berLength
into this function.
Contact us at info@vidterra.com.
FAQs
Lightweight JavaScript library for parsing and manipulating MISB KLV metadata
We found that @vidterra/misb.js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.