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:2022. This version of the standard is available for free online. 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 does not yet provide full coverage of the fifth edition of the specification. All elements and attributes in common use are supported, however.

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, VLC and MP4Box (this includes Matroska, ISO-BMFF / CMAF / MP4, WebM, MPEG-2 TS)
  • Subtitles: preliminary support for WebVTT and TTML streams

§Limitations / unsupported features

  • Dynamic MPD manifests, that are used for live streaming/OTT TV
  • XLink with actuate=onRequest semantics
  • Application of MPD patches

Modules§

  • Support for downloading content from DASH MPD media streams.
  • Support for the SCTE-35 standard for insertion of alternate content

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. DASH implementation guidelines indicate that “representations in the same video adaptation set should be alternative encodings of the same source content, encoded such that switching between them does not produce visual glitches due to picture size or aspect ratio differences”.
  • 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 (e.g. 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).
  • When bitstream switching is enabled, the player can seamlessly switch between Representations in the manifest without reinitializing the media decoder. This means fewer perturbations for the viewer when the network conditions change. It requires the media segments to have been encoded respecting a certain number of constraints.
  • 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. If this node is not present, no content protection is applied by the source.
  • Copyright information concerning the media stream.
  • A DASH event, a mechanism allowing the server to send additional information to the DASH client which is synchronized with the media stream. Used for various purposes such as dynamic ad insertion, providing additional metainformation concerning the actors or location at a point in the media stream, providing parental guidance information, or sending custom data to the DASH player application.
  • Period of time for which either failover content or no content/segments exist for the for the parent Representation.
  • Failover Content Segment (FCS). The time and optional duration for which a representation does not represent the main content but a failover version. It can and is also used to represent gaps where no segments are present at all - used within the FailoverContent element.
  • Specifies frame-packing arrangement information of the video media component type.
  • “Inband” events are materialized by the presence of DASHEventMessageBoxes (emsg) in the media segments. The client is informed of their presence by the inclusion of an InbandEventStream element in the AdaptationSet or Representation element.
  • The first media segment in a sequence of Segments. Subsequent segments can be concatenated to this segment to produce a media stream.
  • Provides a textual description of the content, which can be used by the client to allow selection of the desired media stream.
  • Licence acquisition URL for content using Microsoft PlayReady DRM.
  • 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.
  • Initialization data that is specific to the Microsoft PlayReady DRM.
  • The Patch mechanism allows the DASH client to retrieve a patch from the server that contains a set of instructions for replacing certain parts of the MPD manifest with updated information. It is a bandwidth-friendly alternative to retrieving a new version of the full MPD manifest. The MPD patch document is guaranteed to be available between MPD@publishTime and MPD@publishTime + PatchLocation@ttl.
  • 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).
  • Used for audio signaling in the context of the ATSC 3.0 standard for advanced IP-based television broadcasting. A Preselection is a personalization option to produce a “complete audio experience”. Details are specified by the “DASH-IF Interoperability Point for ATSC 3.0” document.
  • Specifies wall‐clock times at which media fragments were produced, to help clients consume the fragments at the same rate at which they were produced. Used by the low-latency streaming extensions to DASH.
  • Metainformation concerning the media stream (title, language, etc.)
  • Specifies that content is suitable for presentation to audiences for which that rating is known to be appropriate, or for unrestricted audiences.
  • 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 “caption”, “subtitle”, “main”, “alternate”, “supplementary”, “commentary”, and “dub” (this is the attribute scheme for @value when the schemeIdUri is “urn:mpeg:dash:role:2011”).
  • Describes a sequence of contiguous Segments with identical duration.
  • Scope of a namespace.
  • Dash specification MPEG extension (SCTE 214) program identification type (indicates how the program content is identified).
  • 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.
  • A SubRepresentation contains information that only applies to one media stream in a Representation.
  • Subsets provide a mechanism to restrict the combination of active Adaptation Sets where an active Adaptation Set is one for which the DASH Client is presenting at least one of the contained Representations.
  • Information used to allow Adaptation Set Switching (for instance, allowing the player to switch between camera angles). This is different from “bitstream switching”.
  • The title of the media stream.
  • Used to synchronize the clocks of the DASH client and server, to allow low-latency streaming.

Enums§

Functions§

Type Aliases§