mpd-parser is a JavaScript library specifically designed for parsing MPEG-DASH (Dynamic Adaptive Streaming over HTTP) Media Presentation Description (MPD) manifests. It takes an XML-formatted MPD string and transforms it into a structured, easily consumable JavaScript object. The current stable version is 1.3.1, released in October 2024. The package follows an active, feature- and bugfix-driven release cadence, typically seeing several minor and patch versions annually. A key differentiator is its tight integration within the Video.js ecosystem, providing robust capabilities for handling complex DASH manifests, including support for live streams through the `previousManifest` option for efficient updates, parsing content steering information, processing EventStreams, and extracting DRM-related `mp4protection` tags. It is widely used in web-based video playback solutions requiring DASH support.
npm install mpd-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to fetch an MPEG-DASH MPD manifest and parse it using `mpd-parser`, including an event handler and showing the output structure.
Review the changelog or source code for `v1.0.0` for specific breaking changes in API surface or parsed output structure. Adapt consumption code accordingly.
When parsing updated manifests for live streams, always include the previously parsed manifest object as `mpdParser.parse(newManifest, { manifestUri, previousManifest: oldParsedManifest })`.Always provide the `manifestUri` option with the URL from which the manifest was fetched: `mpdParser.parse(manifestText, { manifestUri: 'https://example.com/manifest.mpd' })`.Keep `mpd-parser` updated to the latest version to benefit from patched dependencies. Regularly run `npm audit` and address any reported vulnerabilities.
Use `import mpdParser from 'mpd-parser';` and then call `mpdParser.parse(...)`. For CommonJS, use `const mpdParser = require('mpd-parser');` and `mpdParser.parse(...)`.Ensure the `<script>` tag for `mpd-parser` is placed before any inline scripts that attempt to use it, or inside a `DOMContentLoaded` listener.
Validate your MPD XML string using an XML linter or a DASH manifest validator. Check console for specific error messages from the `eventHandler` if one is provided to `mpdParser.parse`.