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.

Synopsis

$ 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 generated 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_live_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.

  • Output DASH + HLS with dash_only and hls_only options

    $ 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,dash_only=1’ ‘in=input_text.vtt,stream=text,segment_template=text/$Number$.vtt,hls_only=1’ ‘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_live_mpd –mpd_output h264.mpd –hls_master_playlist_output h264_master.m3u8

The above packaging command creates HLS playlists and DASH manifest while using dash_only for creating segmented WebVTT in mp4 format and hls_only option for creating WebVTT in text format.

Configuration options

DASH specific stream descriptor fields

dash_accessibilities (accessibilities)

Optional semicolon separated list of values for DASH Accessibility element. The value should be in the format: scheme_id_uri=value, which propagates to the Accessibility element in the result DASH manifest. See DASH (ISO/IEC 23009-1) specification for details.

dash_roles (roles)

Optional semicolon separated list of values for DASH Role element. The value should be one of: caption, subtitle, main, alternate, supplementary, commentary and dub. See DASH (ISO/IEC 23009-1) specification for details.

DASH options

--generate_static_live_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 <file_path>

MPD output file name.

--base_urls <comma_separated_urls>
Comma separated BaseURLs for the MPD:

<url>[,<url>]….

The values will be added as <BaseURL> element(s) immediately under the <MPD> element.

--min_buffer_time <seconds>

Specifies, in seconds, a common duration used in the definition of the MPD Representation data rate.

--minimum_update_period <seconds>

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 <seconds>

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 <seconds>

Guaranteed duration of the time shifting buffer for dynamic media presentations, in seconds.

--preserved_segments_outside_live_window <num_segments>

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 <scheme_id_uri_value_pairs>
Comma separated UTCTiming schemeIdUri and value pairs for the MPD:

<scheme_id_uri>=<value>[,<scheme_id_uri>=<value>]…

This value is used for dynamic MPD only.

--default_language <language>

Any audio/text tracks tagged with this language will have <Role … value="main" /> 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 <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.

–dash_only=0|1

Optional. Defaults to 0 if not specified. If it is set to 1, indicates the stream is DASH only.

--allow_codec_switching

If enabled, allow adaptive switching between different codecs, if they have the same language, media type (audio, video etc) and container type.

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.