{"library":"mpd-parser","title":"MPEG-DASH MPD Parser","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install mpd-parser"],"cli":null},"imports":["import mpdParser from 'mpd-parser';","const mpdParser = require('mpd-parser');","var mpdParser = window['mpd-parser'];"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import mpdParser from 'mpd-parser';\n\nasync function parseMpdManifest(manifestUri) {\n  try {\n    // Fetch the MPD manifest from the given URI\n    const res = await fetch(manifestUri);\n    if (!res.ok) {\n      throw new Error(`Failed to fetch manifest: ${res.statusText}`);\n    }\n    const manifestText = await res.text();\n\n    // A callback function to handle events like errors or warnings during parsing\n    const eventHandler = ({ type, message }) => console.log(`[MPD Parser Event] ${type}: ${message}`);\n\n    // Parse the manifest, providing the manifestUri for relative URL resolution\n    const parsedManifest = mpdParser.parse(manifestText, { manifestUri, eventHandler });\n\n    console.log('Parsed Manifest:', parsedManifest);\n    \n    // Example for live streams: on subsequent calls, pass the previous manifest\n    // const newManifestText = await fetch(manifestUri).then(r => r.text());\n    // const updatedParsedManifest = mpdParser.parse(newManifestText, { manifestUri, previousManifest: parsedManifest, eventHandler });\n    // console.log('Updated Parsed Manifest (Live):', updatedParsedManifest);\n\n    return parsedManifest;\n  } catch (error) {\n    console.error('Error parsing MPD manifest:', error);\n    throw error;\n  }\n}\n\n// Example usage: Replace with an actual MPD URI\nconst exampleManifestUri = 'https://dash.akamaized.net/envivio/EnvivioDashVoD.mpd';\nparseMpdManifest(exampleManifestUri)\n  .catch(err => console.error('Overall parsing error:', err));","lang":"javascript","description":"Demonstrates how to fetch an MPEG-DASH MPD manifest and parse it using `mpd-parser`, including an event handler and showing the output structure.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}