Crate dash_mpd

source ·
Expand description

A Rust library for parsing, serializing and downloading media content from a DASH MPD manifest, as used for on-demand replay of TV content and video streaming services. Allows both parsing of a DASH manifest (XML format) to Rust structs (deserialization) and programmatic generation of an MPD manifest (serialization). The library also allows you to download media content from a streaming server. DASH (dynamic adaptive streaming over HTTP), also called MPEG-DASH, is a technology used for media streaming over the web, commonly used for video on demand (VOD) services. The Media Presentation Description (MPD) is a description of the resources (manifest or “playlist”) forming a streaming service, that a DASH client uses to determine which assets to request in order to perform adaptive streaming of the content. DASH MPD manifests can be used both with content encoded as MPEG and as WebM.

This library provides a serde-based parser (deserializer) and serializer for the DASH MPD format, as formally defined in ISO/IEC standard 23009-1:2019. XML schema files are available for no cost from ISO. When MPD files in practical use diverge from the formal standard, this library prefers to interoperate with existing practice.

The library also provides experimental support for downloading content (audio or video) described by an MPD manifest. This involves selecting the alternative with the most appropriate encoding (in terms of bitrate, codec, etc.), fetching segments of the content using HTTP or HTTPS requests (this functionality depends on the reqwest crate) and muxing audio and video segments together (using ffmpeg via the ac_ffmpeg crate).

DASH features supported

  • VOD (static) stream manifests
  • Multi-period content
  • XLink elements (only with actuate=onLoad semantics, resolve-to-zero supported)
  • All forms of segment index info: SegmentBase@indexRange, SegmentTimeline, SegmentTemplate@duration, SegmentTemplate@index, SegmentList
  • Media containers of types supported by mkvmerge, ffmpeg or VLC (this includes Matroska, ISO-BMFF / CMAF / MP4, WebM, MPEG-2 TS)

Limitations / unsupported features

  • Dynamic MPD manifests, that are used for live streaming/OTT TV
  • Encrypted content using DRM such as Encrypted Media Extensions (EME) and Media Source Extension (MSE)
  • Subtitles (eg. WebVTT and TTML streams)
  • XLink with actuate=onRequest

Modules

Support for downloading content from DASH MPD media streams.

Structs

Specifies the accessibility scheme used by the media content.
Contains a set of Representations. For example, if multiple language streams are available for the audio content, each one can be in its own AdaptationSet.
Identifies the asset to which a given Period belongs. Can be used to implement client functionality that depends on distinguishing between ads and main content.
Specifies information concerning the audio channel (eg. stereo, multichannel).
A URI string that specifies one or more common locations for Segments and other resources, used as a prefix for SegmentURLs. Can be specified at the level of the MPD node, or Period, AdaptationSet, Representation, and can be nested (the client should combine the prefix on MPD and on Representation, for example).
A Common Encryption “Protection System Specific Header” box. Content is typically base64 encoded.
Describes a media content component.
Contains information on DRM (rights management / encryption) mechanisms used in the stream, such as Widevine and Playready. Note that this library is not able to download content with DRM. If this node is not present, no content protection is applied by the source.
Copyright information concerning the media stream.
A DASH event.
The first media segment in a sequence of Segments. Subsequent segments can be concatenated to this segment to produce a media stream.
A URI string to which a new request for an updated manifest should be made. This feature is intended for servers and clients that can’t use sticky HTTP redirects.
The root node of a parsed DASH MPD manifest.
Describes a chunk of the content with a start time and a duration. Content can be split up into multiple periods (such as chapters, advertising segments).
Metainformation concerning the media stream (title, language, etc.)
A representation describes a version of the content, using a specific encoding and bitrate. Streams often have multiple representations with different bitrates, to allow the client to select that most suitable to its network conditions (adaptive bitrate or ABR streaming).
The purpose of this media stream, such as captions, subtitle, main, alternate, supplementary, commentary, and dub.
Describes a sequence of contiguous Segments with identical duration.
Specifies some common information concerning media segments.
Contains a sequence of SegmentURL elements.
Allows template-based SegmentURL construction. Specifies various substitution rules using dynamic values such as $Time$ and $Number$ that map to a sequence of Segments.
Contains a sequence of S elements, each of which describes a sequence of contiguous segments of identical duration.
The URL of a media segment.
The original source of the media stream.
The title of the media stream.

Enums

Functions

Returns true if this AdaptationSet contains audio content.
Returns true if this AdaptationSet contains subtitle content.
Returns true if this AdaptationSet contains video content.
Parse an MPD manifest, provided as an XML string, returning an MPD node.

Type Definitions

Type representing an xs:dateTime, as per https://www.w3.org/TR/xmlschema-2/#dateTime