This project provides tools for working with MPEG-DASH manifests in JSON format:
- XSD to JSON Schema Converter - Converts MPEG-DASH XSD schemas to JSON Schema format
- MPD to JSON Converter - Converts MPD XML manifests to validated JSON
- JSON to MPD Converter - Converts JSON back to MPD XML (round-trip support)
This project generates schemas compliant with JSON Schema 2020-12, the latest stable version of the JSON Schema specification:
- Core: https://json-schema.org/draft/2020-12/json-schema-core
- Validation: https://json-schema.org/draft/2020-12/json-schema-validation
- Relative JSON Pointer: https://datatracker.ietf.org/doc/html/draft-bhutton-relative-json-pointer-00
npm installConvert a DASH MPD XML manifest to JSON format with validation:
npm run mpd2json -- <input.mpd> [options]
# Example: Convert with full validation
npm run mpd2json -- manifest.mpd -o manifest.json
# Example: Skip XSD validation (faster)
npm run mpd2json -- manifest.mpd --skip-xsd -o manifest.json
# Example: Verbose mode
npm run mpd2json -- manifest.mpd -v -o manifest.jsonmpd2json <input.mpd> [options]
Options:
-o, --output <file> Output JSON file (default: stdout)
--xsd <path> Path to XSD schema (default: xml-schemas/DASH-MPD.xsd)
--json-schema <path> Path to JSON Schema (default: output/dash-mpd.schema.json)
--skip-xsd Skip XSD validation
--skip-json-schema Skip JSON Schema validation
--no-pretty Output minified JSON
-v, --verbose Show detailed validation messages
-h, --help Show help
The converter performs the following steps:
- XSD Validation - Validates the input MPD against the DASH-MPD XSD schema (using
xmllint) - XML to JSON Conversion - Converts XML to JSON matching our schema structure
- JSON Schema Validation - Validates the output JSON against the generated JSON Schema
Convert an XSD file to JSON Schema:
npm run convert <input.xsd> -o <output.json>
# Example
npm run convert xml-schemas/DASH-MPD.xsd -o output/dash-mpd.schema.jsonxsd2jsonschema <input.xsd> [options]
Options:
-o, --output <file> Output file (default: stdout)
--base-uri <uri> Base URI for $id in the schema
--attr-prefix <prefix> Prefix for XML attributes (e.g., '@')
--no-pretty Output minified JSON
-h, --help Show help
| XSD Construct | JSON Schema Equivalent |
|---|---|
xs:string |
"type": "string" |
xs:integer |
"type": "integer" |
xs:boolean |
"type": "boolean" |
xs:double |
"type": "number" |
xs:dateTime |
"type": "string", "format": "date-time" |
xs:duration |
"type": "string" with ISO 8601 pattern |
xs:anyURI |
"type": "string", "format": "uri-reference" |
xs:enumeration |
"enum": [...] |
xs:pattern |
"pattern": "..." |
xs:minInclusive/maxInclusive |
"minimum"/"maximum" |
xs:complexType |
"type": "object" with "properties" |
xs:sequence |
"properties" + "required" |
xs:choice |
"oneOf" |
xs:extension |
"allOf" with "$ref" |
xs:list |
"type": "array" |
The xml-schemas/ directory contains the MPEG-DASH XSD schemas:
- DASH-MPD.xsd - Main Media Presentation Description schema
- CENC.xsd - Common Encryption schema
- xlink.xsd - XLink attributes
- DASH-MPD-UP.xsd - URL parameters extension
- DASH-MPD-PATCH.xsd - MPD patch operations
Generated JSON Schemas are written to the output/ directory:
dash-mpd.schema.json- Complete DASH MPD schema (~70KB, 98 type definitions)cenc.schema.json- CENC typesxlink.schema.json- XLink typesdash-mpd-up.schema.json- URL parameter types
When converting MPD XML to JSON, the following conventions are used:
| XML Construct | JSON Representation |
|---|---|
| Element with text content only (no attributes in schema) | "Element": "text value" |
| Element with text + possible attributes (defined in schema) | "Element": { "$value": "text", "attr": "value" } |
| Repeated elements | "Element": [...] (array) |
| Attributes | Direct properties on the object |
| Namespace declarations | Root-level $ns object mapping URIs to prefixes |
Namespaced attributes (e.g., xlink:href) |
Grouped under prefix key (e.g., "xlink": { "href": "..." }) |
| Extension elements | Grouped under prefix key (e.g., "ext": { "CustomElement": ... }) |
Note: Elements use $value for text content when the XSD schema defines possible attributes for that element type, even if no attributes are present in a particular instance. This ensures consistent JSON structure.
XML:
<BaseURL availabilityTimeOffset="5.0">https://example.com/video/</BaseURL>JSON:
{
"BaseURL": [{
"$value": "https://example.com/video/",
"availabilityTimeOffset": 5.0
}]
}XML:
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
xmlns:xlink="http://www.w3.org/1999/xlink">
<Period id="p0" xlink:href="http://example.com/period.xml" xlink:actuate="onLoad"/>
</MPD>JSON:
{
"$ns": {
"http://www.w3.org/1999/xlink": {
"prefix": "xlink",
"attributes": ["href", "actuate"]
}
},
"Period": [{
"id": "p0",
"xlink": {
"href": "http://example.com/period.xml",
"actuate": "onLoad"
}
}]
}Namespace declarations are collected at the root $ns object only. Each prefix maps to exactly one URI and vice versa. See docs/dash-json-representation.md Section 9 for the full specification.
- Node.js 18+
- xmllint (for XSD validation) - typically pre-installed on macOS/Linux
# Build TypeScript
npm run build
# Run tests
npm testMIT