Skip to content

Phoenix35/mk-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Matroska EBML Parser

This is not a substitute for the amazing MediaInfo program.
It just parses the headers of a matroska file and return a JSON with the info I deem important.

How to use

Feed a matroska (mkv, mk3d, mka, or mks) file.

/**
 * The only function you should care about
 * @param {File/Blob} mkFile - The matroska file 
 */
mkInputFile(mkFile)

Output

A javascript object is returned.

name: {string} The name of the file
size: {integer} The size of the file (in bytes)
duration: {string} The duration of the file (in nanoseconds)

The differents tracks are in the tracks object. Always ≥ 1 track(s).

Tracks

id: {integer} The identification number of the track = 1 (!)
type: {string} The type of stream (video, audio, subtitle) = 1 (!)
name: {string} The name of the track (default = '')
language: {string} The language of the track using ISO639-2 (default = '')

Videos tracks

= 1 (!) for mkv, mk3d
= 0 (!) otherwise
width: {integer} The width of the video
height: {integer} The height of the video

Audio tracks

≥ 1 (!) for mka
= 0 for mks
≥ 0 otherwise

Subtitle tracks

≥ 1 (!) for mks
≥ 0 otherwise

Example

If you didn't understand the crap above, here is a concrete, human-friendly, example.

Psycho Pass 2 - 01 vostfr

// on a dragdrop event for example
let result = mk.inputFile(e.dataTransfer.files[0]);

// after processing, this should be your output
result = {
  name: 'Psycho Pass 2 - 01 vostfr BD [x264_AC3][HI10p][1920x1080].mkv',
  size: 857381271, // equals to 818 MiB
  UID: <UInt8Array> 0x94858110C7CFC0BBA60A8EBD4DDEBBC0
  duration: 1341760000000, // => 00:22:21.760
  tracks: [
    {
      id: 1,
      type: 'video',
      name: '',
      language: 'jpn',
      width: 1920,
      height: 1080
    },
    {
      id: 2,
      type: 'audio',
      name: '',
      language: 'jpn'
    },
    {
      id: 3,
      type: 'subtitle',
      name: 'Piste sans honorifiques',
      language: 'fra'
    },
    {
      id: 4,
      type: 'subtitle',
      name: 'Piste avec honorifiques',
      language: 'fra'
    }
  ]
}

Browser support

Anything that supports ECMAScript6.
Firefox, Chrome, IE 11+...
I do not intend to support older browsers. Sorry. Too bad.

License

Creative Commons License
Matroska EBML Parser by https://github.com/Phoenix35/mk-parser is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

forthebadge

About

A javascript parser for matroska meta datas

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published