Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

mpd-parser

videojs2.6mApache-2.01.3.1

mpd parser

videojs, videojs-plugin

readme

mpd-parser

Build Status Greenkeeper badge Slack Status

NPM

mpd parser

Table of Contents

Installation

npm install --save mpd-parser

Usage

// get your manifest in whatever way works best
// for example, by reading the file from the filesystem in node
// or using fetch in a browser like so:

const manifestUri = 'https://example.com/dash.xml';
const res = await fetch(manifestUri);
const manifest = await res.text();

// A callback function to handle events like errors or warnings
const eventHandler = ({ type, message }) => console.log(`${type}: ${message}`);

var parsedManifest = mpdParser.parse(manifest, { manifestUri, eventHandler });

If dealing with a live stream, then on subsequent calls to parse, the previously parsed manifest object should be provided as an option to parse using the previousManifest option:

const newParsedManifest = mpdParser.parse(
  manifest,
  // parsedManifest comes from the prior example
  { manifestUri, previousManifest: parsedManifest }
);

Parsed Output

The parser ouputs a plain javascript object with the following structure:

Manifest {
  allowCache: boolean,
  contentSteering: {
    defaultServiceLocation: string,
    proxyServerURL: string,
    queryBeforeStart: boolean,
    serverURL: string
  },
  endList: boolean,
  mediaSequence: number,
  discontinuitySequence: number,
  playlistType: string,
  playlists: [
    {
      attributes: {},
      Manifest
    }
  ],
  mediaGroups: {
    AUDIO: {
      'GROUP-ID': {
        default: boolean,
        autoselect: boolean,
        language: string,
        uri: string,
        instreamId: string,
        characteristics: string,
        forced: boolean
      }
    },
    VIDEO: {},
    'CLOSED-CAPTIONS': {},
    SUBTITLES: {}
  },
  dateTimeString: string,
  dateTimeObject: Date,
  targetDuration: number,
  totalDuration: number,
  discontinuityStarts: [number],
  segments: [
    {
      byterange: {
        length: number,
        offset: number
      },
      duration: number,
      attributes: {},
      discontinuity: number,
      uri: string,
      timeline: number,
      key: {
        method: string,
        uri: string,
        iv: string
      },
      map: {
        uri: string,
        byterange: {
          length: number,
          offset: number
        }
      },
      'cue-out': string,
      'cue-out-cont': string,
      'cue-in': string
    }
  ]
}

Including the Parser

To include mpd-parser on your website or web application, use any of the following methods.

<script> Tag

This is the simplest case. Get the script in whatever way you prefer and include it on your page.

<script src="//path/to/mpd-parser.min.js"></script>
<script>
  var mpdParser = window['mpd-parser'];
  var parsedManifest = mpdParser.parse(manifest, { manifestUri });
</script>

Browserify

When using with Browserify, install mpd-parser via npm and require the parser as you would any other module.

var mpdParser = require('mpd-parser');

var parsedManifest = mpdParser.parse(manifest, { manifestUri });

With ES6:

import { parse } from 'mpd-parser';

const parsedManifest = parse(manifest, { manifestUri });

RequireJS/AMD

When using with RequireJS (or another AMD library), get the script in whatever way you prefer and require the parser as you normally would:

require(['mpd-parser'], function(mpdParser) {
  var parsedManifest = mpdParser.parse(manifest, { manifestUri });
});

License

Apache-2.0. Copyright (c) Brightcove, Inc

changelog

1.3.1 (2024-10-09)

Bug Fixes

  • ensure vtt tracks language is set correctly (#181) (b48d2a5)

1.3.0 (2023-12-08)

Features

  • parse mp4protection ContentProtection tags (#179) (0813929)

Chores

1.2.2 (2023-08-30)

Bug Fixes

  • improve serviceLocation for content steering (#177) (fee1870)

1.2.1 (2023-08-16)

Bug Fixes

1.2.0 (2023-08-15)

Features

Chores

1.1.1 (2023-03-31)

Bug Fixes

1.1.0 (2023-03-20)

Features

  • add EventStream support (f1a09ca)
  • set label for vttPlaylist from label when available (#161) (3fc0486)

Chores

  • update xmldom dependency (cfcb568)

1.0.0 (2022-08-19)

Features

  • add support for a frame-rate attribute (#159) (cd75be1)

Chores

BREAKING CHANGES

  • Internet Explorer is no longer supported.

0.21.1 (2022-04-05)

Bug Fixes

  • DASH content protection schemeIdUri as lowercase (#157) (aa02006), closes #156
  • update to vhs-utils 3.0.5 for tizen 2.4 support (#158) (d7003a3)

0.21.0 (2021-12-17)

Features

  • support multi-period live DASH with changing periods (#152) (fe886d0)

BREAKING CHANGES

  • period start time (periodStart) is now used as the timeline instead of period index (periodIndex)

0.20.0 (2021-11-29)

Features

Chores

Documentation

0.19.2 (2021-10-06)

Bug Fixes

  • caption services are allowed not to have a value (#151) (c9803f1)

0.19.1 (2021-09-22)

Bug Fixes

  • mark global/window/document as external globals (#148) (2f82ff8)

0.19.0 (2021-08-24)

Features

  • add presentationTime as an attribute on each SegmentList segment (#142) (478abb0)

Chores

BREAKING CHANGES

  • the presentationTimeOffset attribute has been removed from output

0.18.0 (2021-07-28)

Features

  • add Period@start attribute when missing (#137) (f118a8b)
  • add presentationTime as an attribute on each SegmentTemplate segment (#139) (a972b8c)

Bug Fixes

  • generate proper number of segments for multiperiod content that uses segment template (#138) (39109d0)

Code Refactoring

  • default MPD@type to static when missing (#136) (281e035)
  • rename master manifest to main manifest (#141) (5720fbd)
  • rename SegmentInfo property from timeline to segmentTimeline (#140) (1601467)

0.17.0 (2021-05-28)

Features

Chores

0.16.0 (2021-03-26)

Features

  • add a binary to convert mpd to m3u8 json in node (#129) (608aa9d)
  • expose presentationTimeOffset on segments that have it (#81) (8b58b39)
  • parse Label element and use as m3u8 group label (#113) (5dde0e9)

Bug Fixes

  • bump xmldom to prevent npm security issue (#122) (e132e40)
  • support multiple audio/subtitle playlists and export generateSidxKey (#123) (f7105d8)

Chores

  • fix publish, add bin to files, update vjsverify (cb4d772)

Documentation

  • better explain how to update the JS manifest files (#130) (21aa91c)
  • update usage example in README (#127) (f0da2cc)

0.15.4 (2021-02-24)

An accidental republish of 0.15.3 with no changes.

0.15.3 (2021-02-24)

Features

  • add support for endNumber in template duration parsing (#120) (0a75d62)

0.15.2 (2021-01-12)

Bug Fixes

0.15.1 (2021-01-11)

Chores

0.15.0 (2020-11-17)

Features

Bug Fixes

Chores

Tests

0.14.0 (2020-11-03)

Chores

0.13.0 (2020-09-29)

Features

  • add CODECS attribute to subtitle playlists if it exists (#106) (bc0872a)

0.12.0 (2020-09-03)

Features

  • remove default value of 0 for minimumUpdatePeriod (#103) (38ca9ad)

BREAKING CHANGES

  • The minimumUpdatePeriod property is now omitted from parsed output if it is not present in the manifest, rather than using a default value of 0. This is to allow differentiation between cases when a value of 0 is present in the manifest and when no value is provided.

0.11.0 (2020-08-12)

Features

0.10.1 (2020-03-31)

Bug Fixes

  • don't adjust mediaPresentationDuration by timescale for segment duration when using SegmentBase (#94) (40cdd00)

0.10.0 (2020-02-04)

Features

  • expose suggestPresentationDelay if the type is dynamic (#82) (cd27003)

0.9.0 (2019-08-30)

Features

0.8.2 (2019-08-22)

Chores

0.8.1 (2019-05-01)

Bug Fixes

0.8.0 (2019-04-11)

Features

  • add sidx information to segment base playlists (#41) (1176109)

Bug Fixes

Chores

  • add netlify for testing (#45) (a78a7be)
  • Update videojs-generate-karma-config to the latest version 🚀 (#37) (a18c660)
  • Update videojs-generate-karma-config to the latest version 🚀 (#38) (3aaabac)
  • Update videojs-generate-rollup-config to the latest version 🚀 (#36) (3f6ccbd)
  • package: update videojs-generate-karma-config to 5.0.2 (#54) (fcbabc3)
  • package: videojs-generate-karma-config@4.0.0 does not exist (#44) (bc361b5)

0.7.0 (2018-10-24)

Features

Bug Fixes

  • fixed segment timeline parsing when duration is present (#34) (90feb2d)
  • Remove the postinstall script to prevent install issues (#29) (ae458f4)

Chores

  • Update to generator-videojs-plugin@7.2.0 (#28) (909cf08)
  • package: Update dependencies to enable Greenkeeper 🌴 (#30) (0593c2c)

0.6.1 (2018-05-17)

Bug Fixes

0.6.0 (2018-03-30)

Features

0.5.0 (2018-03-15)

Features

0.4.0 (2018-02-26)

Features

  • Adding support for segments in Period and Representation. (#19) (8e59b38)

0.3.0 (2018-02-06)

Features

  • Parse <SegmentList> and <SegmentBase> (#18) (71b8976)
  • Support for inheriting BaseURL and alternate BaseURLs (#17) (7dad5d5)
  • add support for SegmentTemplate padding format string and SegmentTimeline (#16) (87933f6)

0.2.1 (2017-12-15)

Bug Fixes

  • access HTMLCollections with IE11 compatibility (#15) (5612984)

0.2.0 (2017-12-12)

Features

Tests

0.1.1 (2017-12-07)

Bug Fixes

  • avoid using Array.prototype.fill for IE support (#11) (5c444de)

0.1.0 (2017-11-29)

Bug Fixes

  • switch off in-manifest caption support (#8) (15712c6)

CHANGELOG

HEAD (Unreleased)

(none)