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§

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

Structs§

Accessibility
Specifies the accessibility scheme used by the media content.
AdaptationSet
Contains a set of Representations.
AssetIdentifier
Identifies the asset to which a given Period belongs.
AudioChannelConfiguration
Specifies information concerning the audio channel (e.g. stereo, multichannel).
BaseURL
A URI string that specifies one or more common locations for Segments and other resources.
BitstreamSwitching
Information on the bitstream switching capabilities for Representations.
CencPssh
A Common Encryption “Protection System Specific Header” box. Content is typically base64 encoded.
ContentComponent
Describes a media content component.
ContentProtection
Contains information on DRM (rights management / encryption) mechanisms used in the stream.
Copyright
Copyright information concerning the media stream.
EssentialProperty
Event
A mechanism allowing the server to send additional information to the DASH client which is synchronized with the media stream.
EventStream
FailoverContent
Period of time for which either failover content or no content/segments exist for the parent Representation.
Fcs
Failover Content Segment (FCS).
FramePacking
Specifies frame-packing arrangement information of the video media component type.
InbandEventStream
“Inband” events are materialized by the presence of DASHEventMessageBoxes (emsg) in the media segments.
Initialization
The first media segment in a sequence of Segments.
Label
Provides a textual description of the content, which can be used by the client to allow selection of the desired media stream.
Language
Latency
Laurl
Licence acquisition URL for content using Microsoft PlayReady DRM.
LeapSecondInformation
Location
A URI string to which a new request for an updated manifest should be made.
MPD
The root node of a parsed DASH MPD manifest.
Metrics
MsprIVSize
MsprIsEncrypted
MsprKid
MsprPro
Initialization data that is specific to the Microsoft PlayReady DRM.
OutputProtection
PatchLocation
The Patch mechanism allows the DASH client to retrieve a set of instructions for replacing certain parts of the MPD manifest with updated information.
Period
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).
PlaybackRate
Preselection
A Preselection is a personalization option to produce a “complete audio experience”.
ProducerReferenceTime
Specifies wall‐clock times at which media fragments were produced.
ProgramInformation
Metainformation concerning the media stream (title, language, etc.)
Range
Rating
Specifies that content is suitable for presentation to audiences for which that rating is known to be appropriate, or for unrestricted audiences.
Reporting
Representation
A Representation describes a version of the content, using a specific encoding and bitrate.
RepresentationIndex
Resync
Role
The Role specifies the purpose of this media stream (caption, subtitle, main content, etc.).
S
Describes a sequence of contiguous Segments with identical duration.
Scope
Scope of a namespace.
Scte214ContentIdentifier
DASH specification MPEG extension (SCTE 214) program identification type.
SegmentBase
Specifies some common information concerning media segments.
SegmentList
Contains a sequence of SegmentURL elements.
SegmentTemplate
Allows template-based SegmentURL construction. Specifies various substitution rules using dynamic values such as $Time$ and $Number$ that map to a sequence of Segments.
SegmentTimeline
Contains a sequence of S elements, each of which describes a sequence of contiguous segments of identical duration.
SegmentURL
The URL of a media segment.
Selection
SelectionInfo
ServiceDescription
Source
The original source of the media stream.
SubRepresentation
A SubRepresentation contains information that only applies to one media stream in a Representation.
Subset
Subsets provide a mechanism to restrict the combination of active Adaptation Sets.
SupplementalProperty
Switching
Information used to allow Adaptation Set Switching (for instance, allowing the player to switch between camera angles).
Title
The title of the media stream.
UTCTiming
Used to synchronize the clocks of the DASH client and server, to allow low-latency streaming.
Viewpoint

Enums§

DashMpdError
SubtitleType

Functions§

check_conformity
Returns a list of DASH conformity errors in the DASH manifest mpd.
is_audio_adaptation
Returns true if this AdaptationSet contains audio content.
is_subtitle_adaptation
Returns true if this AdaptationSet contains subtitle content.
is_video_adaptation
Returns true if this AdaptationSet contains video content.
parse
Parse an MPD manifest, provided as an XML string, returning an MPD node.
subtitle_type

Type Aliases§

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