Amazon Vinyl logo Amazon Vinyl v3.2.1

@amazon/vinyl-mpd-parser

Website npm size

A fast, schema-validated DASH manifest parser for browser and Node. Parses .mpd documents into a typed object that mirrors the MPEG-DASH 2011 schema, with built-in support for the cenc and Microsoft PlayReady content protection namespaces. Validates against the schema as it parses, surfacing the exact source location for invalid documents.

Install

npm install @amazon/vinyl-mpd-parser

Usage

import { parseDashManifest } from '@amazon/vinyl-mpd-parser'

const text = await (await fetch(mpdUri)).text()
const manifest = parseDashManifest(text)

for (const period of manifest.MPD.Period) {
    for (const adaptationSet of period.AdaptationSet ?? []) {
        console.log(adaptationSet.contentType, adaptationSet.Representation)
    }
}

The parser is built on top of @amazon/vinyl-xml. To extend the rule set with additional namespaces, merge your own XmlRules into the parser following the same pattern used internally for content protection.

License

Apache-2.0