# DASH¶

Dynamic Adaptive Streaming over HTTP (DASH) is an adaptive bitrate streaming technique that enables high quality streaming of media content over HTTP.

Shaka Packager supports DASH content packaging. This tutorial covers DASH packaging of VOD content without encryption. For live content packaging, see Live; for content encryption, see DRM; for full documentation, see Packager Documentation.

$packager <stream_descriptor> ... \ --mpd_output <manifest_output_path> \ [Other DASH options] \ [Other options, e.g. DRM options, HLS options]  See DASH options for the available DASH related options. Note DASH and HLS options can both be specified to output DASH and HLS manifests at the same time. Note that it works only for MP4 outputs. ## Examples¶ The examples below uses the H264 streams created in Media Encoding. It can be applied to VP9 in the same way. • on-demand: $ packager \
in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4 \
in=input_text.vtt,stream=text,output=output_text.vtt \
in=h264_baseline_360p_600.mp4,stream=video,output=h264_360p.mp4 \
in=h264_main_480p_1000.mp4,stream=video,output=h264_480p.mp4 \
in=h264_main_720p_3000.mp4,stream=video,output=h264_720p.mp4 \
in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4 \
--mpd_output h264.mpd


The above packaging command creates five single track fragmented mp4 streams (4 video, 1 audio), a subtitle file and a manifest, which describes the streams.

• on-demand with trick-play tracks:

$packager \ in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4 \ in=input_text.vtt,stream=text,output=output_text.vtt \ in=h264_baseline_360p_600.mp4,stream=video,output=h264_360p.mp4 \ in=h264_main_480p_1000.mp4,stream=video,output=h264_480p.mp4 \ in=h264_main_720p_3000.mp4,stream=video,output=h264_720p.mp4 \ in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4 \ in=h264_main_480p_1000.mp4,stream=video,output=h264_480p.mp4,trick_play_factor=1 \ in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4,trick_play_factor=1 \ --mpd_output h264.mpd  The above packaging command creates two extra trick play tracks, besides the files genereated with the previous command. • static-live: $ packager \
'in=h264_baseline_360p_600.mp4,stream=audio,init_segment=audio/init.mp4,segment_template=audio/$Number$.m4s' \
'in=input_text.vtt,stream=text,init_segment=text/init.mp4,segment_template=text/$Number$.m4s' \
'in=h264_baseline_360p_600.mp4,stream=video,init_segment=h264_360p/init.mp4,segment_template=h264_360p/$Number$.m4s' \
'in=h264_main_480p_1000.mp4,stream=video,init_segment=h264_480p/init.mp4,segment_template=h264_480p/$Number$.m4s' \
'in=h264_main_720p_3000.mp4,stream=video,init_segment=h264_720p/init.mp4,segment_template=h264_720p/$Number$.m4s' \
'in=h264_high_1080p_6000.mp4,stream=video,init_segment=h264_1080p/init.mp4,segment_template=h264_1080p/$Number$.m4s' \
--generate_static_mpd --mpd_output h264.mpd


The above packaging command creates five groups of segments (each with an init segment and a series of media segments) for the five streams and a manifest, which describes the streams.

• Single file MP4 output with DASH + HLS:

$packager \ in=h264_baseline_360p_600.mp4,stream=audio,output=audio.mp4,playlist_name=audio.m3u8,hls_group_id=audio,hls_name=ENGLISH \ in=h264_baseline_360p_600.mp4,stream=video,output=h264_360p.mp4,playlist_name=h264_360p.m3u8,iframe_playlist_name=h264_360p_iframe.m3u8 \ in=h264_main_480p_1000.mp4,stream=video,output=h264_480p.mp4,playlist_name=h264_480p.m3u8,iframe_playlist_name=h264_480p_iframe.m3u8 \ in=h264_main_720p_3000.mp4,stream=video,output=h264_720p.mp4,playlist_name=h264_720p.m3u8,iframe_playlist_name=h264_720p_iframe.m3u8 \ in=h264_high_1080p_6000.mp4,stream=video,output=h264_1080p.mp4,playlist_name=h264_1080p.m3u8,iframe_playlist_name=h264_1080p_iframe.m3u8 \ --hls_master_playlist_output h264_master.m3u8 \ --mpd_output h264.mpd  The above packaging command creates five single file MP4 streams, and HLS playlists as well as DASH manifests. ## Configuration options¶ ### DASH options¶  --generate_static_mpd If enabled, generates static mpd. If segment_template is specified in stream descriptors, shaka-packager generates dynamic mpd by default; if this flag is enabled, shaka-packager generates static mpd instead. Note that if segment_template is not specified, shaka-packager always generates static mpd regardless of the value of this flag. --mpd_output MPD output file name. --base_urls Comma separated BaseURLs for the MPD: [,]…. The values will be added as element(s) immediately under the element. --min_buffer_time Specifies, in seconds, a common duration used in the definition of the MPD Representation data rate. --minimum_update_period Indicates to the player how often to refresh the media presentation description in seconds. This value is used for dynamic MPD only. --suggested_presentation_delay Specifies a delay, in seconds, to be added to the media presentation time. This value is used for dynamic MPD only. --time_shift_buffer_depth Guaranteed duration of the time shifting buffer for dynamic media presentations, in seconds. --preserved_segments_outside_live_window Segments outside the live window (defined by time_shift_buffer_depth above) are automatically removed except for the most recent X segments defined by this parameter. This is needed to accommodate latencies in various stages of content serving pipeline, so that the segments stay accessible as they may still be accessed by the player. The segments are not removed if the value is zero. --utc_timings Comma separated UTCTiming schemeIdUri and value pairs for the MPD: =[,=]… This value is used for dynamic MPD only. --default_language Any audio/text tracks tagged with this language will have in the manifest. This allows the player to choose the correct default language for the content. This applies to both audio and text tracks. The default language for text tracks can be overriden by ‘default_text_language’. --default_text_language Same as above, but this applies to text tracks only, and overrides the default language for text tracks. --allow_approximate_segment_timeline For live profile only. If enabled, segments with close duration (i.e. with difference less than one sample) are considered to have the same duration. This enables MPD generator to generate less SegmentTimeline entries. If all segments are of the same duration except the last one, we will do further optimization to use SegmentTemplate@duration instead and omit SegmentTimeline completely. Ignored if$Time$is used in segment template, since$Time$requires accurate Segment Timeline. ### Segment template formatting¶ The implementation is based on Template-based Segment URL construction described in ISO/IEC 23009-1:2014. Supported identifiers$<Identifier>$Substitution parameter Format $$is an escape sequence, i.e. “$$” is replaced with a single “$”. Not applicable.
$Number$ This identifier is substitued with the number of the corresponding Segment.

The format tag may be present.

If no format tag is present, a default format tag with width=1 shall be used.

$Time$ This identifier is substituted with the value of the SegmentTimeline@t attribute for the Segment being accessed. Either $Number$ or $Time$ may be used but not both at the same time.

The format tag may be present.

If no format tag is present, a default format tag with width=1 shall be used.

Note

Identifiers $RepresentationID$ and $Bandwidth$ are not supported in this version. Please file an issue if you want it to be supported.

In each URL, the identifiers shall be replaced by the substitution parameter per the definition in the above table. Identifier matching is case-sensitive.

Each identifier may be suffixed, within the enclosing ‘\$’ characters, with an additional format tag aligned with the printf format tag as defined in IEEE 1003.1-2008 following this prototype:

%0[width]d


The width parameter is an unsigned integer that provides the minimum number of characters to be printed. If the value to be printed is shorter than this number, the result shall be padded with zeros. The value is not truncated even if the result is larger.

Strings outside identifiers shall only contain characters that are permitted within URLs according to RFC 3986.