

# Integrating a content source for MediaTailor ad insertion
<a name="integrating-origin"></a>

This topic covers integrating different types of video content sources with MediaTailor. MediaTailor supports both HLS and DASH streaming protocols for live and on-demand content. The service can perform ad insertion or replacement during designated ad breaks, and has specific requirements for the structure and formatting of the input video manifests to enable these capabilities. The following topics provide details on the input source requirements and steps for integrating HLS and DASH content with MediaTailor to enable personalized ad experiences.

**Topics**
+ [Input source requirements for MediaTailor ad insertion](stream-reqmts.md)
+ [Integrating an HLS source](manifest-hls.md)
+ [Integrating an MPEG-DASH source](manifest-dash.md)
+ [Securing AWS Elemental MediaTailor origin interactions with SigV4](origin-sigv4.md)

# Input source requirements for MediaTailor ad insertion
<a name="stream-reqmts"></a>

A input source must meet the following requirements to work with MediaTailor:
+ Use Apple HLS (HTTP Live Streaming) or MPEG DASH (Dynamic Adaptive Streaming over HTTP)
+ Use live streaming or video on demand (VOD)
+ Be accessible on the public internet and have a public IP address
+ Use standard HTTP ports (port 80) or HTTPS ports (port 443). MediaTailor does not support custom ports for origin server communication.
+ Contain ad markers in one of the formats described in the [Getting started with MediaTailor ad insertion tutorial](getting-started-ad-insertion.md#getting-started-prep-stream) 

# Integrating an HLS source
<a name="manifest-hls"></a>

AWS Elemental MediaTailor supports `.m3u8` HLS manifests with an `EXT-X-VERSION` of `3` or higher for live streaming and video on demand (VOD). When MediaTailor encounters an ad break, it attempts ad insertion or replacement, based on the type of content. If there aren't enough ads to fill the duration, for the remainder of the ad break, MediaTailor displays the underlying content stream or the configured slate. For more information about HLS ad behavior based on content type, see [Understanding AWS Elemental MediaTailor ad insertion behavior](ad-behavior.md).

The following sections provide more information about how MediaTailor handles HLS manifests.

**Topics**
+ [HLS supported ad markers](hls-ad-markers.md)
+ [Enabling ad marker passthrough](ad-marker-passthrough.md)
+ [HLS manifest tag handling](manifest-hls-tags.md)
+ [HLS manifest examples](manifest-hls-example.md)

# HLS supported ad markers
<a name="hls-ad-markers"></a>

AWS Elemental MediaTailor identifies ad avail boundaries in an HLS manifest by parsing the input manifest for supported ad markers. The following sections describe what markers MediaTailor uses.

## EXT-X-ASSET
<a name="hls-ad-markers-asset"></a>

The `EXT-X-ASSET` tag contains metadata that's used by the ad decision server (ADS) to personalize content for the viewer. `EXT-X-ASSET` parameters are comma-separated key-value pairs.

To use this tag, you must meet the following requirements:
+ You must URL-encode the `EXT-X-ASSET` *values* in the origin manifest. The following example shows the `EXT-X-ASSET` tag with keys and URL-encoded values.

  ```
              #EXT-X-ASSET:GENRE=CV,CAID=12345678,EPISODE="Episode%20Name%20Date",SEASON="Season%20Name%20and%20Number",SERIES="Series%2520Name"
  ```
+ You must include the dynamic `[asset.]` variable and the *keys* in your MediaTailor ADS configuration. The following example shows an MediaTailor ADS configuration using the dynamic `[asset.]` variable and keys.

  ```
              https://myads.com/stub?c=[asset.GENRE]&g=[asset.CAID]&e=[asset.EPISODE]&s=[asset.SEASON]&k=[asset.SERIES]
  ```

**Example VAST request**  
The following example shows a VAST `GET` request to an ADS.

```
            https://myads.com/stub?c=CV&g=12345678&e=Episode%20Name%20Date&s=Season%20Name%20and%20Number&k=Series%2520Name
```

## EXT-X-CUE-OUT and EXT-X-CUE-IN
<a name="hls-ad-markers-cue"></a>

This type of ad marker is the most common. The following examples show options for these cue markers.

```
#EXT-X-CUE-OUT:DURATION=120
    ...
    #EXT-X-CUE-IN
```

```
#EXT-X-CUE-OUT:30.000
    ...
    #EXT-X-CUE-IN
```

```
#EXT-X-CUE-OUT
    ...
    #EXT-X-CUE-IN
```

## EXT-X-DATERANGE
<a name="hls-ad-markers-range"></a>

With `EXT-X-DATERANGE` ad marker tags, you use `SCTE35-OUT` attributes to specify the timing of the ad avail. 

**Note**  
AWS Elemental MediaTailor ignores any `START-DATE` attributes that are provided for `EXT-X-DATERANGE` ad markers. 

You can specify the ad avail in one of the following ways:
+ `EXT-X-DATERANGE` tag with `SCTE35-OUT` and `DURATION` specifications. 

  Example

  ```
  #EXT-X-DATERANGE:ID="splice-6FFFFFF0",START-DATE="2019-01T00:15:00Z\",DURATION=60.000,SCTE35-OUT=0xF
  ```
+ Paired `EXT-X-DATERANGE` tags, the first with a `SCTE35-OUT` specification and the second with a `SCTE35-IN` specification. 

  Example

  ```
  #EXT-X-DATERANGE:ID="splice-6FFFFFF0",START-DATE="2019-01T00:15:00Z\",SCTE35-OUT=0xF
      ...
      #EXT-X-DATERANGE:ID="splice-6FFFFFF0",START-DATE="2019-01T00:15:00Z\",SCTE35-IN=0xF
  ```
+ A combination of the prior options. You specify an `EXT-X-DATERANGE` tag with `SCTE35-OUT` and `DURATION` specifications followed by an `EXT-X-DATERANGE` tag with a `SCTE35-IN` specification. In this case, MediaTailor uses the earliest cue-in setting from the two specifications.

  Example

  ```
  #EXT-X-DATERANGE:ID="splice-6FFFFFF0",START-DATE="2019-01T00:15:00Z\",DURATION=60.000,SCTE35-OUT=0xF
      ...
      #EXT-X-DATERANGE:ID="splice-6FFFFFF0",START-DATE="2019-01T00:15:00Z\",SCTE35-IN=0xF
  ```

## EXT-X-SPLICEPOINT-SCTE35
<a name="hls-ad-markers-splice"></a>

You append the `EXT-X-SPLICEPOINT-SCTE35` ad marker tag with a SCTE-35 payload in base64-encoded binary. The decoded binary must provide a SCTE-35 `splice_info_section` containing the cue-out marker `0x34`, for provider placement opportunity start, and the cue-in marker `0x35`, for provider placement opportunity end. 

The following example shows the splice point specification with base64-encoded binary payloads that specify the cue-out and cue-in markers. 

```
    #EXT-X-SPLICEPOINT-SCTE35:/DA9AAAAAAAAAP/wBQb+uYbZqwAnAiVDVUVJAAAKqX//AAEjW4AMEU1EU05CMDAxMTMyMjE5M19ONAAAmXz5JA==
    ...
    #EXT-X-SPLICEPOINT-SCTE35:/DA4AAAAAAAAAP/wBQb+tTeaawAiAiBDVUVJAAAKqH+/DBFNRFNOQjAwMTEzMjIxOTJfTjUAAIiGK1s=
```

# Enabling ad marker passthrough
<a name="ad-marker-passthrough"></a>

By default for HLS, MediaTailor personalized manifests don't include the SCTE-35 ad markers from the origin manifests. When ad marker passthrough is enabled, MediaTailor passes through the following ad markers from origin manifests into personalized manifests:
+ EXT-X-CUE-IN
+ EXT-X-CUE-OUT
+ EXT-X-SPLICEPOINT-SCTE35

 Ad marker passthrough is an optional setting. Use ad marker passthrough if you want the SCTE ad markers to be included in the MediaTailor personalized manifest. Common use cases include the following: 
+ Content replacement - Perform content replacement or content restriction.
+ Ad tracking - Trigger ad tracking information based on the presence or absence of one or more ad markers.
+ Player settings - Enable scrubbing or countdown timer functionality in the player's UI, based on the presence or absence of ad markers.

**Note**  
MediaTailor doesn't change the values for these markers. For example, if `EXT-X-CUE-OUT` has a value of `60` in the origin manifest, but no ads are placed, MediaTailor won't change the value to `0` in the personalized manifest. 

## Enable ad marker passthrough
<a name="enable-ad-marker-passthrough"></a>

You can enable ad marker passthrough using the AWS Management Console or the AWS Command Line Interface (AWS CLI).

**To enable ad marker passthrough using the console**

1. Open the MediaTailor console at [https://console.aws.amazon.com/mediatailor/](https://console.aws.amazon.com/mediatailor/).

1.  Select either **New Configuration** or **Edit Configuration**.

1. In the **Advanced Settings** section, select **Enable** from the drop down menu.

**To enable ad marker passthrough using the AWS Command Line Interface (AWS CLI)**  
Use the [put-playback-configuration](https://docs.aws.amazon.com/cli/latest/reference/mediatailor/put-playback-configuration.html) command.

# HLS manifest tag handling
<a name="manifest-hls-tags"></a>

This section describes how AWS Elemental MediaTailor manages tags in the personalized output manifest.

## EXT-X-CUE tags
<a name="manifest-hls-tags-cue"></a>

MediaTailor replaces `EXT-X-CUE-OUT`, `EXT-X-CUE-OUT-CONT`, and `EXT-X-CUE-IN` tags in the input manifest with `EXT-X-DISCONTINUITY` tags in the output manifest. The `DISCONTINUITY` tags mark the following boundaries:
+ Where the main content transitions to an ad
+ Where one ad transitions to another ad
+ Where an ad transitions back to the main content

## EXT-X-DATERANGE tags
<a name="manifest-hls-tags-daterange"></a>

MediaTailor passes through `EXT-X-DATERANGE` tags from the input manifest to the output manifest. MediaTailor also inserts `EXT-X-DISCONTINUITY` tags that correspond to the `DATERANGE` tags. The `DISCONTINUITY` tags mark the following boundaries:
+ Where the main content transitions to an ad
+ Where one ad transitions to another ad
+ Where an ad transitions back to the main content

## EXT-X-KEY tags
<a name="manifest-hls-tags-key"></a>

MediaTailor passes through `EXT-X-KEY` tags from the input manifest. These tags indicate that the main content is encrypted. Since ads aren't encrypted, MediaTailor inserts `EXT-X-KEY:METHOD=NONE` at the start of an ad avail. When playback returns to the main content, MediaTailor re-enables encryption by inserting the `EXT-X-KEY` tag with the `METHOD` value defined as the encryption type.

## Unrecognized tags
<a name="manifest-hls-tags-unknown"></a>

MediaTailor passes through all unknown and custom tags from the input manifest to the output manifest.

# HLS manifest examples
<a name="manifest-hls-example"></a>

The following sections provide examples of HLS origin manifests and personalized manifests. Understanding these examples can help you configure and troubleshoot your MediaTailor workflows.

For information about how query parameters are applied to HLS manifests and segments, see [MediaTailor HLS implicit session initialization](manifest-query-parameters-hls-implicit-session-initialization.md).

## Understanding HLS playlist types
<a name="hls-playlist-overview"></a>

HTTP Live Streaming (HLS) uses two primary types of playlists:

Multivariant playlist  
A multivariant playlist is the top-level index file that lists all available renditions of the content. It contains references to media playlists but does not contain any media segments itself. This playlist allows players to select the most appropriate rendition based on network conditions, device capabilities, or user preferences.  
This playlist type is also known by several other names in various contexts, including master playlist, master manifest, primary playlist, main playlist, index file, or master M3U8.  
In MediaTailor workflows, the multivariant playlist is the entry point for playback requests and is where ad personalization begins.

Media playlist  
A media playlist contains the actual media segment information for a specific rendition (quality level) of the content. It includes timing information, segment URLs, and other metadata required for playback of a single rendition.  
This playlist type is also known as media playlist, child manifest, chunklist, media M3U8, or rendition playlist.  
In MediaTailor workflows, media playlists are personalized to include both content segments and ad segments in the proper sequence.

For more detailed information about HLS playlist types, see [HLS playlist types](hls-playlist-types.md).

## HLS origin manifest examples
<a name="manifest-hls-ex-origin"></a>

The following example shows an HLS multivariant playlist that AWS Elemental MediaTailor received by HLS from the content origin.

```
#EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-INDEPENDENT-SEGMENTS
    #EXT-X-STREAM-INF:BANDWIDTH=2665726,AVERAGE-BANDWIDTH=2526299,RESOLUTION=960x540,FRAME-RATE=29.970,CODECS="avc1.640029,mp4a.40.2",SUBTITLES="subtitles"
    index_1.m3u8
    #EXT-X-STREAM-INF:BANDWIDTH=3956044,AVERAGE-BANDWIDTH=3736264,RESOLUTION=1280x720,FRAME-RATE=29.970,CODECS="avc1.640029,mp4a.40.2",SUBTITLES="subtitles"
    index_2.m3u8
    #EXT-X-STREAM-INF:BANDWIDTH=995315,AVERAGE-BANDWIDTH=951107,RESOLUTION=640x360,FRAME-RATE=29.970,CODECS="avc1.4D401E,mp4a.40.2",SUBTITLES="subtitles"
    index_3.m3u8
    #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subtitles",NAME="caption_1",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,LANGUAGE="eng",URI="index_4_0.m3u8"
```

In this multivariant playlist example:
+ The `#EXT-X-STREAM-INF` tags define different renditions with varying resolutions and bitrates
+ Each rendition references a media playlist (such as `index_1.m3u8`)
+ The `#EXT-X-MEDIA` tag defines a subtitle track

The following example shows an HLS media playlist that AWS Elemental MediaTailor received by HLS from the content origin. This example uses `EXT-X-CUE-OUT` and `EXT-X-CUE-IN` tags to describe ad avail opportunities.

```
#EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-TARGETDURATION:7
    #EXT-X-MEDIA-SEQUENCE:8779957
    #EXTINF:6.006,
    index_1_8779957.ts?m=1566416212
    #EXTINF:6.006,
    index_1_8779958.ts?m=1566416212
    #EXTINF:5.372,
    index_1_8779959.ts?m=1566416212
    #EXT-OATCLS-SCTE35:/DAlAAAAAsvhAP/wFAXwAAAGf+/+AdLfiP4AG3dAAAEBAQAAXytxmQ==
    #EXT-X-CUE-OUT:20.020
    #EXTINF:0.634,
    index_1_8779960.ts?m=1566416212
    #EXT-X-CUE-OUT-CONT:ElapsedTime=0.634,Duration=21,SCTE35=/DAlAAAAAsvhAP/wFAXwAAAGf+/+AdLfiP4AG3dAAAEBAQAAXytxmQ==
    #EXTINF:6.006,
    index_1_8779961.ts?m=1566416212
    #EXT-X-CUE-OUT-CONT:ElapsedTime=6.640,Duration=21,SCTE35=/DAlAAAAAsvhAP/wFAXwAAAGf+/+AdLfiP4AG3dAAAEBAQAAXytxmQ==
    #EXTINF:6.006,
    index_1_8779962.ts?m=1566416212
    #EXT-X-CUE-OUT-CONT:ElapsedTime=12.646,Duration=21,SCTE35=/DAlAAAAAsvhAP/wFAXwAAAGf+/+AdLfiP4AG3dAAAEBAQAAXytxmQ==
    #EXTINF:6.006,
    index_1_8779963.ts?m=1566416212
    #EXT-X-CUE-OUT-CONT:ElapsedTime=18.652,Duration=21,SCTE35=/DAlAAAAAsvhAP/wFAXwAAAGf+/+AdLfiP4AG3dAAAEBAQAAXytxmQ==
    #EXTINF:1.368,
    index_1_8779964.ts?m=1566416212
    #EXT-X-CUE-IN
    #EXTINF:4.638,
    index_1_8779965.ts?m=1566416212
    #EXTINF:6.006,
    index_1_8779966.ts?m=1566416212
    #EXTINF:6.006,
    index_1_8779967.ts?m=1566416212
    #EXTINF:6.006,
    index_1_8779968.ts?m=1566416212
```

In this media playlist example:
+ The `#EXTINF` tags specify the duration of each segment
+ The `#EXT-X-CUE-OUT` tag marks the beginning of an ad break
+ The `#EXT-X-CUE-OUT-CONT` tags provide information about the ongoing ad break
+ The `#EXT-X-CUE-IN` tag marks the end of the ad break

## HLS personalized manifest examples
<a name="manifest-hls-ex-personalized"></a>

The following example shows an HLS multivariant playlist that AWS Elemental MediaTailor personalized.

```
#EXTM3U
    #EXT-X-VERSION:3
    #EXT-X-MEDIA:LANGUAGE="eng",AUTOSELECT=YES,FORCED=NO,TYPE=SUBTITLES,URI="../../../manifest/43f3e412052f2808dd84ea1da90e92e914edddee/external-canary-hls/ee1696a8-4f7f-4c4c-99de-9821131847e8/3.m3u8",GROUP-ID="subtitles",DEFAULT=YES,NAME="caption_1"
    #EXT-X-INDEPENDENT-SEGMENTS
    #EXT-X-STREAM-INF:CODECS="avc1.640029,mp4a.40.2",AVERAGE-BANDWIDTH=2526299,RESOLUTION=960x540,SUBTITLES="subtitles",FRAME-RATE=29.97,BANDWIDTH=2665726
    ../../../manifest/43f3e412052f2808dd84ea1da90e92e914edddee/external-canary-hls/ee1696a8-4f7f-4c4c-99de-9821131847e8/0.m3u8
    #EXT-X-STREAM-INF:CODECS="avc1.640029,mp4a.40.2",AVERAGE-BANDWIDTH=3736264,RESOLUTION=1280x720,SUBTITLES="subtitles",FRAME-RATE=29.97,BANDWIDTH=3956044
    ../../../manifest/43f3e412052f2808dd84ea1da90e92e914edddee/external-canary-hls/ee1696a8-4f7f-4c4c-99de-9821131847e8/1.m3u8
    #EXT-X-STREAM-INF:CODECS="avc1.4D401E,mp4a.40.2",AVERAGE-BANDWIDTH=951107,RESOLUTION=640x360,SUBTITLES="subtitles",FRAME-RATE=29.97,BANDWIDTH=995315
    ../../../manifest/43f3e412052f2808dd84ea1da90e92e914edddee/external-canary-hls/ee1696a8-4f7f-4c4c-99de-9821131847e8/2.m3u8
```

Notice how MediaTailor has modified the media playlist URLs to include session-specific information that enables personalized ad insertion.

The following example shows a media playlist that AWS Elemental MediaTailor personalized.

```
#EXTM3U
    #EXT-X-VERSION:6
    #EXT-X-TARGETDURATION:7
    #EXT-X-MEDIA-SEQUENCE:8779957
    #EXT-X-DISCONTINUITY-SEQUENCE:0
    #EXTINF:6.006,
    https://777788889999.mediapackage.us-west-2.amazonaws.com/out/v1/e309ffd02ba8498d864dcaacff7a5ad9/index_1_8779957.ts?m=1566416212
    #EXTINF:6.006,
    https://777788889999.mediapackage.us-west-2.amazonaws.com/out/v1/e309ffd02ba8498d864dcaacff7a5ad9/index_1_8779958.ts?m=1566416212
    #EXTINF:5.372,
    https://777788889999.mediapackage.us-west-2.amazonaws.com/out/v1/e309ffd02ba8498d864dcaacff7a5ad9/index_1_8779959.ts?m=1566416212
    #EXT-X-DISCONTINUITY
    #EXTINF:3.066667,
    ../../../../segment/43f3e412052f2808dd84ea1da90e92e914edddee/external-canary-hls/ee1696a8-4f7f-4c4c-99de-9821131847e8/0/8779960
    #EXTINF:3.0,
    ../../../../segment/43f3e412052f2808dd84ea1da90e92e914edddee/external-canary-hls/ee1696a8-4f7f-4c4c-99de-9821131847e8/0/8779961
    #EXTINF:3.0,
    ../../../../segment/43f3e412052f2808dd84ea1da90e92e914edddee/external-canary-hls/ee1696a8-4f7f-4c4c-99de-9821131847e8/0/8779962
    #EXTINF:3.0,
    ../../../../segment/43f3e412052f2808dd84ea1da90e92e914edddee/external-canary-hls/ee1696a8-4f7f-4c4c-99de-9821131847e8/0/8779963
    #EXTINF:2.966667,
    ../../../../segment/43f3e412052f2808dd84ea1da90e92e914edddee/external-canary-hls/ee1696a8-4f7f-4c4c-99de-9821131847e8/0/8779964
    #EXT-X-DISCONTINUITY
    #EXTINF:6.006,
    https://777788889999.mediapackage.us-west-2.amazonaws.com/out/v1/e309ffd02ba8498d864dcaacff7a5ad9/index_1_8779963.ts?m=1566416212
    #EXTINF:1.368,
    https://777788889999.mediapackage.us-west-2.amazonaws.com/out/v1/e309ffd02ba8498d864dcaacff7a5ad9/index_1_8779964.ts?m=1566416212
    #EXTINF:4.638,
    https://777788889999.mediapackage.us-west-2.amazonaws.com/out/v1/e309ffd02ba8498d864dcaacff7a5ad9/index_1_8779965.ts?m=1566416212
    #EXTINF:6.006,
    https://777788889999.mediapackage.us-west-2.amazonaws.com/out/v1/e309ffd02ba8498d864dcaacff7a5ad9/index_1_8779966.ts?m=1566416212
    #EXTINF:6.006,
    https://777788889999.mediapackage.us-west-2.amazonaws.com/out/v1/e309ffd02ba8498d864dcaacff7a5ad9/index_1_8779967.ts?m=1566416212
    #EXTINF:6.006,
    https://777788889999.mediapackage.us-west-2.amazonaws.com/out/v1/e309ffd02ba8498d864dcaacff7a5ad9/index_1_8779968.ts?m=1566416212
```

In this personalized media playlist example:
+ MediaTailor has inserted ad segments between the content segments
+ The `#EXT-X-DISCONTINUITY` tags mark the transitions between content and ads
+ Content segments are served from the origin server (MediaPackage in this example)
+ Ad segments are served from MediaTailor's ad segment storage

## Key differences in personalized manifests
<a name="manifest-hls-key-differences"></a>

When MediaTailor personalizes HLS manifests, it makes several important changes:

Multivariant playlist changes  
+ Variant playlist URLs are rewritten to point to MediaTailor-managed URLs that include session information
+ The order of tags may be reorganized for optimal playback

Variant playlist changes  
+ Ad markers (`EXT-X-CUE-OUT`, `EXT-X-CUE-IN`) are replaced with actual ad segments
+ Discontinuity markers (`EXT-X-DISCONTINUITY`) are added at content/ad boundaries
+ Content segment URLs are rewritten to point to the origin or CDN
+ Ad segment URLs are added to point to MediaTailor's ad segment storage

Understanding these changes can help you troubleshoot issues in your MediaTailor workflows and ensure proper configuration of your CDN and player.

## Related topics
<a name="manifest-hls-related-topics"></a>

For more information about HLS manifests and MediaTailor, see the following topics:
+ [HLS playlist types](hls-playlist-types.md) - Detailed explanation of HLS playlist types
+ [Using a CDN to optimize MediaTailor ad personalization and content delivery](integrating-cdn.md) - Information about using a CDN with MediaTailor
+ [How MediaTailor ad insertion works](what-is-flow.md) - Overview of how MediaTailor ad insertion works

# Integrating an MPEG-DASH source
<a name="manifest-dash"></a>

AWS Elemental MediaTailor supports `.mpd` live and video on demand (VOD) manifests that follow the guidelines for the DASH dynamic profile. MediaTailor accepts multi-period and single-period DASH-compliant manifest inputs, and delivers multi-period DASH-compliant manifest outputs. 

Input manifests must have the following:
+ SCTE-35 event streams with splice info settings for either `splice insert `or` time signal`. The settings can be provided in clear XML or in base64-encoded binary. 
+ `Segment templates` with `segment timelines`. 

For published manifests, MediaTailor requires that updates from the origin server leave the following unchanged: 
+ Period start times, specified in the `start` attribute. 
+ Values of `presentationTimeOffset` in the segment templates of the period representations. 

As a best practice, give the ad avails the same `AdaptationSet` and `Representation` settings as the content stream periods. AWS Elemental MediaTailor uses these settings to transcode the ads to match the content stream, for smooth switching between the two.

The following sections provide more information about how MediaTailor handles ads in DASH manifests.

**Topics**
+ [DASH ad markers](dash-ad-markers.md)
+ [DASH ad avail duration](dash-ad-avail-duration.md)
+ [DASH manifest segment numbering](dash-manifest-segment-numbering.md)
+ [DASH MPD examples](manifest-dash-example.md)
+ [DASH location feature](dash-location-feature.md)

# DASH ad markers
<a name="dash-ad-markers"></a>

MediaTailor 

AWS Elemental MediaTailor uses SCTE-35 cue-out markers to identify ad avails in the DASH manifest using the following logic: 
+ **Multi-period DASH**: MediaTailor inserts ads for the first `Event` in each `Period` that contains either `SpliceInsert` or `TimeSignal` cue-out markers. MediaTailor ignores additional `Event` markers in the `Period`.
+ **Single-period DASH**: MediaTailor inserts ads each `Event` in the `Period` that contains either `SpliceInsert` or `TimeSignal` cue-out markers.

By default, AWS Elemental MediaTailor manages DASH manifests as multi-period manifests. You can change your configuration to handle single-period DASH manifests from your origin server. For information, see [Creating an MediaTailor playback configuration](configurations-create.md).

The following sections provide additional detail about DASH ad marker handling and provides decorated manifests from the origin.

## DASH origin manifest XML requirements
<a name="dash-ad-markers-examples"></a>

Ad markers in DASH manifests from the origin must be formatted properly for MediaTailor to identify ad breaks. The following topics describe these formatting requirements in clear XML.

### `SpliceInsert` in clear XML
<a name="dash-splice-xml"></a>

`SpliceInsert` ad markers in clear XML must contain the following:
+ `EventStream` must have the following attribute: `schemeIdUri=urn:scte:scte35:2013:xml`
+ `Event` must hold `scte35:SpliceInfoSection` 
+ `scte35:SpliceInfoSection` must hold `scte35:SpliceInsert` 
+ `scte35:SpliceInsert` must have the following attribute: `outOfNetworkIndicator="true"`

**Example `SpliceInsert` in XML**  
In the following example, required SCTE markers are in bold.   

```
<Period start="PT444806.040S" id="123586" duration="PT15.000S">
  <EventStream timescale="90000" schemeIdUri="urn:scte:scte35:2013:xml">
    <Event duration="1350000">
      <scte35:SpliceInfoSection protocolVersion="0" ptsAdjustment="180832" tier="4095">
        <scte35:SpliceInsert spliceEventId="4026531855" spliceEventCancelIndicator="false" outOfNetworkIndicator="true" spliceImmediateFlag="false" uniqueProgramId="1" availNum="1" availsExpected="1">
            <scte35:Program><scte35:SpliceTime ptsTime="5672624400"/></scte35:Program>
            <scte35:BreakDuration autoReturn="true" duration="1350000"/>
        </scte35:SpliceInsert>
      </scte35:SpliceInfoSection>
    </Event>
  .
  .
  .
</Period>
```

### `TimeSignal` in clear XML
<a name="dash-signal-xml"></a>

`TimeSignal` ad markers in clear XML must contain the following:
+ `EventStream` must have the following attribute: `schemeIdUri=urn:scte:scte35:2013:xml`
+ `Event` must hold `scte35:SpliceInfoSection`
+ `scte35:SpliceInfoSection` must hold `scte35:TimeSignal`
+ `scte35:SpliceInfoSection` must also hold `scte35:SegmentationDescriptor`
+ `scte35:SegmentationDescriptor` must have the following attribute, where the value is a valid [Cue-out numbers](#dash-signal-xml-values): `segmentationTypeId="xx"`
+ `scte35:SegmentationDescriptor` must hold `scte35:SegmentationUpid` 
<a name="dash-signal-xml-values"></a>
**Cue-out numbers**  
The following are supported cue-out numbers for the `segmentationTypeId`.


| Segmentation message | segmentationTypeId value | Hexadecimal value | 
| --- | --- | --- | 
| Distributor advertisement end | 51 | 0x51 | 
| Distributor advertisement start | 50 | 0x32 | 
| Distributor placement opportunity end | 55 | 0x37 | 
| Distributor placement opportunity start | 54 | 0x36 | 
| End break | 35 | 0x23 | 
| Provider advertisement end | 49 | 0x31 | 
| Provider advertisement start | 48 | 0x30 | 
| Provider overlay placement opportunity end | 57 | 0x39 | 
| Provider overlay placement opportunity start | 56 | 0x38 | 
| Provider placement opportunity end | 53 | 0x35 | 
| Provider placement opportunity start | 52 | 0x34 | 
| Start break | 34 | 0x22 | 

**Example `TimeSignal` in XML**  
In the following example, required SCTE markers are in bold.   

```
<Period start="PT346530.250S" id="178443" duration="PT61.561S">
  <EventStream timescale="90000" schemeIdUri="urn:scte:scte35:2013:xml">
    <Event duration="5310000">
      <scte35:SpliceInfoSection protocolVersion="0" ptsAdjustment="183003" tier="4095">
        <scte35:TimeSignal>
          <scte35:SpliceTime ptsTime="3442857000"/>
         </scte35:TimeSignal>
        <scte35:SegmentationDescriptor segmentationEventId="1414668" segmentationEventCancelIndicator="false" segmentationDuration="8100000" segmentationTypeId="52" segmentNum="0" segmentsExpected="0">
            <scte35:DeliveryRestrictions webDeliveryAllowedFlag="false" noRegionalBlackoutFlag="false" archiveAllowedFlag="false" deviceRestrictions="3"/>
            <scte35:SegmentationUpid segmentationUpidType="12" segmentationUpidLength="2">0100</scte35:SegmentationUpid>
          </scte35:SegmentationDescriptor>
        </scte35:SpliceInfoSection>
    </Event>
  .
  .
  .
</Period>
```

## DASH origin manifest base64-encoded binary requirements
<a name="dash-base64"></a>

Ad markers in DASH manifests from the origin must be formatted properly for MediaTailor to identify ad breaks. The following topics describe these formatting requirements in base64-encoded binary.

Both `TimeSignal` and `SpliceInsert` ad markers in base64-encoded manifests must contain the following:
+ `EventStream` must have the following attribute: `urn:scte:scte35:2014:xml+bin`
+ `Event` must hold `scte35:Signal`
+ `scte35:Signal` must hold `scte35:Binary` that contains a base64-encoded binary. 

The decoded binary must provide a `splice_info_section` with the same information as what's required for clear XML ad markers.
+ The command type must be either `splice_insert()` or `time_signal()`
+ The additional settings must comply with those described in [`TimeSignal` in clear XML](#dash-signal-xml) and [`SpliceInsert` in clear XML](#dash-splice-xml).

 The decoded binary must provide a `splice_info_section` with the same set of information as the clear XML would provide in a `scte35:SpliceInfoSection` element. The command type must be either `splice_insert()` or `time_signal()`, and the additional settings must comply with those described previously for clear XML delivery. 

The following example shows this option, with the required markers in bold.

```
<Period start="PT444806.040S" id="123586" duration="PT15.000S">
    <EventStream schemeIdUri="urn:scte:scte35:2014:xml+bin" timescale="1">
      <Event presentationTime="1541436240" duration="24" id="29">
        <scte35:Signal xmlns="http://www.scte.org/schemas/35/2016">
          <scte35:Binary>/DAhAAAAAAAAAP/wEAUAAAHAf+9/fgAg9YDAAAAAAAA25aoh</scte35:Binary>
        </scte35:Signal>
      </Event>
      <Event presentationTime="1541436360" duration="24" id="30">
        <scte35:Signal xmlns="http://www.scte.org/schemas/35/2016">
          <scte35:Binary>QW5vdGhlciB0ZXN0IHN0cmluZyBmb3IgZW5jb2RpbmcgdG8gQmFzZTY0IGVuY29kZWQgYmluYXJ5Lg==</scte35:Binary>
        </scte35:Signal>
      </Event>
  .
  .
  .
</Period>
```

The following is the decoded binary for the first event listed in the preceding example. The setting for `splice_command_type` is 5, which indicates `splice_insert`. 

```
{
        "table_id": 252,
        "section_syntax_indicator": false,
        "private_indicator": false,
        "section_length": 33,
        "protocol_version": 0,
        "encrypted_packet": false,
        "encryption_algorithm": 0,
        "pts_adjustment": 0,
        "cw_index": 0,
        "tier": "0xFFF",
        "splice_command_length": 16,
        "splice_command_type": 5,
        "splice_command": {
          "splice_event_id": 448,
          "splice_event_cancel_indicator": false,
          "out_of_network_indicator": true,
          "program_splice_flag": true,
          "duration_flag": true,
          "splice_immediate_flag": false,
          "utc_splice_time": {
            "time_specified_flag": false,
            "pts_time": null
          },
          "component_count": 0,
          "components": null,
          "break_duration": {
            "auto_return": false,
            "duration": {
              "pts_time": 2160000,
              "wall_clock_seconds": 24.0,
              "wall_clock_time": "00:00:24:00000"
            }
          },
          "unique_program_id": 49152,
          "avail_num": 0,
          "avails_expected": 0
        },
        "splice_descriptor_loop_length": 0,
        "splice_descriptors": null,
        "Scte35Exception": {
          "parse_status": "SCTE-35 cue parsing completed with 0 errors.",
          "error_messages": [],
          "table_id": 252,
          "splice_command_type": 5
        }
      }
```

# DASH ad avail duration
<a name="dash-ad-avail-duration"></a>

During playback, when AWS Elemental MediaTailor encounters an ad avail, it replaces some or all of the avail with ads. MediaTailor starts ad replacement at the beginning of the ad avail and includes ads as follows: 
+ If the ad avail specifies a duration, MediaTailor includes as many ads as it can fit inside the duration boundary, without overwriting content that follows. 
+ If no duration is provided, MediaTailor includes ads until it reaches the end of the ad avail. For multi-period manifests, this is the end of the period. For single-period manifests, this is the end of the event. MediaTailor doesn't play ads past the end of the ad avail and, when it encounters the end, truncates the current ad instead of overwriting the content that follows. 

**How AWS Elemental MediaTailor looks for the ad avail duration**  
AWS Elemental MediaTailor searches for a duration setting in the following order: 

1. `Event` `duration`

1. For splice insert, the `scte35:BreakDuration` `duration`

1. For time signal, the `scte35:SegmentationDescriptor` `segmentationDuration`

If AWS Elemental MediaTailor doesn't find any of these settings, it manages ad inclusion without a duration. 

The following example shows an `Event` that has a `duration`.

```
  <Period start="PT444806.040S" id="123586" duration="PT15.000S">
          <EventStream timescale="90000" schemeIdUri="urn:scte:scte35:2013:xml">
            <Event duration="1350000">
              <scte35:SpliceInfoSection protocolVersion="0" ptsAdjustment="180832" tier="4095">
                <scte35:SpliceInsert spliceEventId="4026531855" spliceEventCancelIndicator="false" outOfNetworkIndicator="true" spliceImmediateFlag="false" uniqueProgramId="1" availNum="1" availsExpected="1">
                  <scte35:Program><scte35:SpliceTime ptsTime="5672624400"/></scte35:Program>
                  <scte35:BreakDuration autoReturn="true" duration="1350000"/>
                </scte35:SpliceInsert>
              </scte35:SpliceInfoSection>
            </Event>
              ...
```

The following example shows ad avail with no duration specified. The `Event` has no `duration` and the `scte35:SpliceInsert` element doesn't contain a `scte35:BreakDuration` child element.

```
  <Period start="PT444836.720S" id="123597" duration="PT12.280S">
          <EventStream timescale="90000" schemeIdUri="urn:scte:scte35:2013:xml">
            <Event>
              <scte35:SpliceInfoSection protocolVersion="0" ptsAdjustment="180832" tier="4095">
                <scte35:SpliceInsert spliceEventId="4026531856" spliceEventCancelIndicator="false" outOfNetworkIndicator="true" spliceImmediateFlag="false" uniqueProgramId="1" availNum="1" availsExpected="1">
                  <scte35:Program><scte35:SpliceTime ptsTime="5675385600"/></scte35:Program>
                </scte35:SpliceInsert>
              </scte35:SpliceInfoSection>
            </Event>
            ...
```

# DASH manifest segment numbering
<a name="dash-manifest-segment-numbering"></a>

MediaTailor supports media segments in `<SegmentTemplate>` that are defined using `<SegmentTimeline>` and the `media` attribute. You can specify the media segment list in the `media` attribute using either the `$Number$` identifier or the `$Time$` identifier.

 The following example shows a `SegmentTemplate` with a `media` attribute setting that uses the `$Number$` identifier.

```
        <SegmentTemplate initialization="index_subtitles_4_0_init.mp4?m=1532451703" media="index_subtitles_4_0_$Number$.mp4?m=1532451703" presentationTimeOffset="1062336677920" startNumber="2349899" timescale="90000">
                <SegmentTimeline>
                  <S d="540540" r="2" t="1062338840080"/>
                  <S d="69069" t="1062340461700"/>
                </SegmentTimeline>
              </SegmentTemplate>
```

 The following example shows a `SegmentTemplate` with a `media` attribute setting that uses the `$Time$` identifier.

```
        <SegmentTemplate initialization="asset_720p_8000K_9_init.mp4" media="asset_720p_8000K_9_$Time$.mp4" startNumber="1" timescale="90000">
                <SegmentTimeline>
                  <S d="180000" r="2" t="0"/>
                  <S d="147000" t="540000"/>
                </SegmentTimeline>
              </SegmentTemplate>
```

# DASH MPD examples
<a name="manifest-dash-example"></a>

The following sections provide examples of DASH origin MPDs and personalized MPDs. Understanding these examples can help you configure and troubleshoot your MediaTailor workflows.

For information about how query parameters are applied to DASH manifests and segments, see [MediaTailor DASH implicit session initialization](manifest-query-parameters-dash-implicit-session-initialization.md).

## Understanding DASH MPD structure
<a name="dash-mpd-overview"></a>

Dynamic Adaptive Streaming over HTTP (DASH) uses a Media Presentation Description (MPD) manifest to deliver streaming content. The MPD is an XML document that describes the structure and availability of media content.

MPD (Media Presentation Description)  
The MPD is the primary manifest file in DASH streaming that describes the structure and availability of media content. It contains information about periods, adaptation sets, representations, and segments that make up the streaming content.  
This manifest type is also known by several other names in various contexts, including DASH manifest, DASH MPD, master manifest (when comparing to HLS), or presentation manifest.  
In MediaTailor workflows, the MPD is the entry point for playback requests and is where ad personalization begins.

Period  
A Period is a temporal section of a DASH presentation. Each Period contains one or more adaptation sets and represents a span of media time. In ad insertion workflows, separate Periods are typically used to delineate between content and ads.  
In MediaTailor workflows, Periods are used to separate main content from ad content, with each ad typically represented by its own Period.

AdaptationSet  
An AdaptationSet groups a set of interchangeable encoded versions of one or several media content components. For example, one AdaptationSet might contain multiple video quality levels, while another might contain multiple audio language options.  
In MediaTailor workflows, AdaptationSets are preserved during ad insertion to maintain consistent media types between content and ads.

Representation  
A Representation is a specific encoded version of the media content within an AdaptationSet. Each Representation typically differs in bitrate, resolution, or other encoding parameters, allowing clients to select the most appropriate version based on network conditions and device capabilities.  
In MediaTailor workflows, Representations in ad Periods are matched as closely as possible to the Representations in content Periods to ensure a smooth viewing experience.

For more detailed information about DASH manifest types, see [DASH manifest types](dash-manifest-types.md).

For information about DASH manifest structure and configuration in AWS Elemental MediaPackage, see the MediaPackage User Guide section on DASH overview.

## Live DASH MPD examples
<a name="dash-manifest-live-examples"></a>

This section provides examples of live DASH MPDs. Each example lists an MPD as received from the origin server and after MediaTailor has personalized the MPD with ads.

### DASH MPD splice insert example
<a name="dash-manifest-splice-insert-example"></a>

**DASH origin MPD example for splice insert**  
The following example from an MPD shows an ad avail in a manifest received by DASH from the content origin. This example uses the `SpliceInsert` marker to indicate an ad avail.

```
<Period start="PT173402.036S" id="46041">
  <EventStream timescale="90000" schemeIdUri="urn:scte:scte35:2013:xml">
    <Event duration="9450000">
      <scte35:SpliceInfoSection protocolVersion="0" ptsAdjustment="183265" tier="4095">
        <scte35:SpliceInsert spliceEventId="99" spliceEventCancelIndicator="false" outOfNetworkIndicator="true" spliceImmediateFlag="false" uniqueProgramId="1" availNum="1" availsExpected="1">
          <scte35:Program><scte35:SpliceTime ptsTime="7835775000"/></scte35:Program>
          <scte35:BreakDuration autoReturn="true" duration="9450000"/>
        </scte35:SpliceInsert>
        <scte35:SegmentationDescriptor segmentationEventId="99" segmentationEventCancelIndicator="false" segmentationDuration="9450000">
          <scte35:DeliveryRestrictions webDeliveryAllowedFlag="true" noRegionalBlackoutFlag="true" archiveAllowedFlag="true" deviceRestrictions="3"/>
          <scte35:SegmentationUpid segmentationUpidType="8" segmentationUpidLength="0"/>
          <scte35:SegmentationTypeID segmentationType="52"/>
          <scte35:SegmentNum segmentNum="1"/>
          <scte35:SegmentsExpected segmentsExpected="1"/>
        </scte35:SegmentationDescriptor>
      </scte35:SpliceInfoSection>
    </Event>
  </EventStream>
  <AdaptationSet mimeType="video/mp4" segmentAlignment="true" subsegmentAlignment="true" startWithSAP="1" subsegmentStartsWithSAP="1" bitstreamSwitching="true">
    <Representation id="1" width="960" height="540" frameRate="30000/1001" bandwidth="1000000" codecs="avc1.4D401F">
      <SegmentTemplate timescale="30000" media="index_video_1_0_$Number$.mp4?m=1528475245" initialization="index_video_1_0_init.mp4?m=1528475245" startNumber="178444" presentationTimeOffset="10395907501">
        <SegmentTimeline>
          <S t="10395907501" d="60060" r="29"/>
          <S t="10397709301" d="45045"/>
        </SegmentTimeline>
      </SegmentTemplate>
    </Representation>
  </AdaptationSet>
  <AdaptationSet mimeType="audio/mp4" segmentAlignment="0" lang="eng">
    <Representation id="2" bandwidth="96964" audioSamplingRate="48000" codecs="mp4a.40.2">
      <SegmentTemplate timescale="48000" media="index_audio_2_0_$Number$.mp4?m=1528475245" initialization="index_audio_2_0_init.mp4?m=1528475245" startNumber="178444" presentationTimeOffset="16633452001">
        <SegmentTimeline>
          <S t="16633452289" d="96256" r="3"/>
          <S t="16633837313" d="95232"/>
          <S t="16633932545" d="96256" r="4"/>
          <S t="16634413825" d="95232"/>
          <S t="16634509057" d="96256" r="5"/>
          <S t="16635086593" d="95232"/>
          <S t="16635181825" d="96256" r="4"/>
          <S t="16635663105" d="95232"/>
          <S t="16635758337" d="96256" r="5"/>
          <S t="16636335873" d="71680"/>
        </SegmentTimeline>
      </SegmentTemplate>
    </Representation>
  </AdaptationSet>
</Period>
```

In this origin MPD example:
+ The `<EventStream>` element contains SCTE-35 markers that indicate ad avails
+ The `<scte35:SpliceInsert>` element provides details about the ad avail
+ The `<scte35:BreakDuration>` element specifies the duration of the ad break
+ The `<AdaptationSet>` elements define the available video and audio streams

**DASH personalized MPD example for splice insert**  
AWS Elemental MediaTailor personalizes the ad avails with advertising specifications. The personalizations reflect the viewer data that is received from the player and the advertising campaigns that are currently underway. 

The following example shows an ad avail after AWS Elemental MediaTailor personalizes it. 

```
<Period id="178443_1" start="PT96H15M30.25S">
  <BaseURL>http://111122223333.cloudfront.net/nbc_fallback_2/</BaseURL>
  <AdaptationSet bitstreamSwitching="false" frameRate="30/1" mimeType="video/mp4" segmentAlignment="true" startWithSAP="1" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
    <SegmentTemplate startNumber="1" timescale="90000"/>
    <Representation bandwidth="10000000" codecs="avc1.640028" height="1080" id="1" width="1920">
      <SegmentTemplate initialization="nbc_fallback_ad_2_1080p_10init.mp4" media="nbc_fallback_ad_2_1080p_10_$Number%09d$.mp4" startNumber="1" timescale="90000">
        <SegmentTimeline>
          <S d="180000" r="13" t="0"/>
          <S d="176940" t="2520000"/>
        </SegmentTimeline>
      </SegmentTemplate>
    </Representation>
    <Representation bandwidth="4000000" codecs="avc1.64001f" height="720" id="2" width="1280">
      <SegmentTemplate initialization="nbc_fallback_ad_2_720p_9init.mp4" media="nbc_fallback_ad_2_720p_9_$Number%09d$.mp4" startNumber="1" timescale="90000">
        <SegmentTimeline>
          <S d="180000" r="13" t="0"/>
          <S d="176940" t="2520000"/>
        </SegmentTimeline>
      </SegmentTemplate>
    </Representation>
  </AdaptationSet>
  <AdaptationSet mimeType="audio/mp4" segmentAlignment="0" lang="eng">
    <Representation id="8" bandwidth="128000" audioSamplingRate="48000" codecs="mp4a.40.2">
      <SegmentTemplate initialization="nbc_fallback_ad_2_audio_2init.mp4" media="nbc_fallback_ad_2_audio_2_$Number%09d$.mp4" startNumber="1" timescale="90000">
        <SegmentTimeline>
          <S d="180000" r="13" t="0"/>
          <S d="176940" t="2520000"/>
        </SegmentTimeline>
      </SegmentTemplate>
    </Representation>
  </AdaptationSet>
</Period>
```

In this personalized MPD example:
+ MediaTailor has created a new Period for the ad content
+ The `<BaseURL>` element points to the ad content location
+ The `<AdaptationSet>` elements maintain similar structure to the content
+ The `<Representation>` elements provide different quality levels for the ad content

### DASH MPD time signal example
<a name="dash-manifest-time-signal-example"></a>

**DASH origin MPD example for time signal**  
The following example from an MPD shows an ad avail in a manifest received by DASH from the content origin. This example uses the `TimeSignal` marker to indicate an ad avail.

```
<Period start="PT173402.036S" id="46041">
  <EventStream timescale="90000" schemeIdUri="urn:scte:scte35:2013:xml">
    <Event duration="9450000">
      <scte35:SpliceInfoSection protocolVersion="0" ptsAdjustment="183265" tier="4095">
        <scte35:TimeSignal>
          <scte35:SpliceTime ptsTime="7835775000"/>
        </scte35:TimeSignal>
        <scte35:SegmentationDescriptor segmentationEventId="99" segmentationEventCancelIndicator="false" segmentationDuration="9450000">
          <scte35:DeliveryRestrictions webDeliveryAllowedFlag="true" noRegionalBlackoutFlag="true" archiveAllowedFlag="true" deviceRestrictions="3"/>
          <scte35:SegmentationUpid segmentationUpidType="8" segmentationUpidLength="0"/>
          <scte35:SegmentationTypeID segmentationType="52"/>
          <scte35:SegmentNum segmentNum="1"/>
          <scte35:SegmentsExpected segmentsExpected="1"/>
        </scte35:SegmentationDescriptor>
      </scte35:SpliceInfoSection>
    </Event>
  </EventStream>
  <AdaptationSet mimeType="video/mp4" segmentAlignment="true" subsegmentAlignment="true" startWithSAP="1" subsegmentStartsWithSAP="1" bitstreamSwitching="true">
    <Representation id="1" width="960" height="540" frameRate="30000/1001" bandwidth="1000000" codecs="avc1.4D401F">
      <SegmentTemplate timescale="30000" media="index_video_1_0_$Number$.mp4?m=1528475245" initialization="index_video_1_0_init.mp4?m=1528475245" startNumber="178444" presentationTimeOffset="10395907501">
        <SegmentTimeline>
          <S t="10395907501" d="60060" r="29"/>
          <S t="10397709301" d="45045"/>
        </SegmentTimeline>
      </SegmentTemplate>
    </Representation>
  </AdaptationSet>
</Period>
```

In this origin MPD example:
+ The `<scte35:TimeSignal>` element is used instead of `<scte35:SpliceInsert>`
+ The `<scte35:SegmentationDescriptor>` provides additional information about the ad avail

**DASH personalized MPD example for time signal**  
AWS Elemental MediaTailor personalizes the ad avails with advertising specifications. The personalizations reflect the viewer data that is received from the player and the advertising campaigns that are currently underway. 

The following example shows an ad avail after AWS Elemental MediaTailor personalizes it. 

```
<Period id="178443_1" start="PT96H15M30.25S">
  <BaseURL>http://111122223333.cloudfront.net/nbc_fallback_2/</BaseURL>
  <AdaptationSet bitstreamSwitching="false" frameRate="30/1" mimeType="video/mp4" segmentAlignment="true" startWithSAP="1" subsegmentAlignment="true" subsegmentStartsWithSAP="1">
    <SegmentTemplate startNumber="1" timescale="90000"/>
    <Representation bandwidth="10000000" codecs="avc1.640028" height="1080" id="1" width="1920">
      <SegmentTemplate initialization="nbc_fallback_ad_2_1080p_10init.mp4" media="nbc_fallback_ad_2_1080p_10_$Number%09d$.mp4" startNumber="1" timescale="90000">
        <SegmentTimeline>
          <S d="180000" r="13" t="0"/>
          <S d="176940" t="2520000"/>
        </SegmentTimeline>
      </SegmentTemplate>
    </Representation>
  </AdaptationSet>
</Period>
```

The personalized MPD for time signal is similar to the one for splice insert, with MediaTailor creating a new Period for the ad content.

## VOD DASH MPD examples
<a name="dash-manifest-vod-examples"></a>

This section provides examples of video on demand (VOD) DASH MPDs. Each example lists an MPD as received from the origin server and after MediaTailor has personalized the MPD with ads.

VOD DASH MPDs follow the same structure as live MPDs, but they typically have a `type="static"` attribute in the MPD element and may contain multiple Periods for different content segments.

For examples of VOD DASH MPDs, see the MediaTailor documentation on [DASH ad markers](dash-ad-markers.md).

## Key differences in personalized MPDs
<a name="dash-manifest-key-differences"></a>

When MediaTailor personalizes DASH MPDs, it makes several important changes:

Period handling  
+ New Periods are created for ad content
+ Period start times are adjusted to maintain timeline continuity
+ EventStream elements with SCTE-35 markers are processed and removed

AdaptationSet and Representation handling  
+ AdaptationSets in ad Periods are created to match content AdaptationSets
+ Representations are created for different quality levels of the ad content
+ SegmentTemplate elements are updated to point to ad content

Understanding these changes can help you troubleshoot issues in your MediaTailor workflows and ensure proper configuration of your CDN and player.

## Related topics
<a name="dash-manifest-related-topics"></a>

For more information about DASH MPDs and MediaTailor, see the following topics:
+ [DASH manifest types](dash-manifest-types.md) - Detailed explanation of DASH manifest types
+ [Using a CDN to optimize MediaTailor ad personalization and content delivery](integrating-cdn.md) - Information about using a CDN with MediaTailor
+ [How MediaTailor ad insertion works](what-is-flow.md) - Overview of how MediaTailor ad insertion works
+ For comprehensive information about DASH manifest structure and MediaPackage configuration, see the MediaPackage User Guide section on DASH overview.

# DASH location feature
<a name="dash-location-feature"></a>

This section provides information about the location feature for DASH, which is enabled by default in AWS Elemental MediaTailor. Read this section if you create content delivery network (CDN) routing rules for accessing MediaTailor manifests. Also read this section if you use server-side reporting with players that don't support sticky HTTP redirects.

**What is the location feature?**  
The location feature allows players that don't support sticky HTTP redirects to provide sticky behavior in their manifest update requests. 

AWS Elemental MediaTailor uses sessionless initialization, and it requires sticky HTTP redirect behavior from its players. With server-side reporting, when the player makes a request for a manifest update to MediaTailor, the service issues a 302 temporary redirect, to direct the player to an endpoint for the personalized manifest. MediaTailor includes a session ID in the response, as a query parameter. The intent is for the player to follow the URL for the entirety of the session, but players that don't support sticky HTTP redirects drop the redirect and return to the original URL. When a player returns to the original URL, for each new request MediaTailor creates a new session rather than staying with the original session. This can cause the manifest to become corrupt. 

The DASH specification provides a solution to this problem in the location feature, which is enabled by default in AWS Elemental MediaTailor configurations. When this feature is enabled, MediaTailor puts the absolute URL in the manifest `<Location>` tag. Players that don't support sticky HTTP redirects can use the URL provided in `<Location>` to request updates to the manifest. 

**Do I need to disable the location feature in my configuration?**  
The location feature overrides any CDN routing rules that you set up for accessing AWS Elemental MediaTailor manifests, so you might need to disable it. The location feature doesn't affect CDN caching of content or ad segments. 

Find your situation in the following list to determine whether you need to disable the location feature for your configuration and how to handle it:
+ If you don't have CDN routing rules set up for accessing AWS Elemental MediaTailor manifests, leave the location setting enabled. 
+ Otherwise, use the following rules:
  + If you either don't use server-side reporting or your players all support sticky HTTP redirects, disable the location feature. For information about how to do this on the console, see [Creating an MediaTailor playback configuration](configurations-create.md).
  + Otherwise, contact [AWS Support](https://aws.amazon.com/premiumsupport/).

**Do I need to use the location feature?**  
You need to use the location feature for players that don't support sticky HTTP redirects. Use the URL provided in the `<Location>` tag for all of your manifest update requests. 

**Example**  
Example URLs and example `<Location>` tag.
+   
**Example: Initial request URL**  

  ```
  https://777788889999.mediatailor.us-east-1.amazonaws.com/v1/dash/5ca4c1892b1f213a1247fad47b3e34c454a7d490/testLocationTag/index.mpd
  ```
+   
**Example: Redirected 302 response**  

  ```
  /v1/dash/5ca4c1892b1f213a1247fad47b3e34c454a7d490/testLocationTag/index.mpd?aws.sessionId=0e5d9b45-ae97-49eb-901b-893d043e0aa6
  ```
+   
**Example: Location tag in a manifest**  

  ```
  <Location>https://777788889999.mediatailor.us-east-1.amazonaws.com/v1/dash/5ca4c1892b1f213a1247fad47b3e34c454a7d490/testLocationTag/index.mpd?aws.sessionId=0e5d9b45-ae97-49eb-901b-893d043e0aa6</Location>
  ```

# Securing AWS Elemental MediaTailor origin interactions with SigV4
<a name="origin-sigv4"></a>

Signature Version 4 (SigV4) is a signing protocol used to authenticate MediaTailor requests to supported origins over HTTPS. MediaTailor only supports HTTPS communication and does not allow HTTP connections. With SigV4 signing, MediaTailor includes a signed authorization header in the HTTPS origin request to MediaTailor Channel Assembly, Amazon S3 and AWS Elemental MediaPackage version 2. 

You can use SigV4 at your origin to ensure that manifest requests are only fulfilled if they’re from MediaTailor and contain a signed authorization header. This way, unauthorized MediaTailor playback configurations are blocked from accessing your origin content. If the signed authorization header is valid, your origin fulfills the request. If it isn't valid, the request fails.

The following sections describe requirements for using MediaTailor SigV4 signing to supported origins.

## MediaTailor Channel Assembly requirements
<a name="origin-sigv4-ca"></a>

If you use SigV4 to protect your MediaTailor Channel Assembly origin, the following requirements must be met for MediaTailor to access the manifest:
+ The origin base URL in your MediaTailor configuration must be a Channel Assembly channel in the following format: `channel-assembly.mediatailor.region.amazonaws.com`
+ Your origin must be configured to use HTTPS. MediaTailor only supports HTTPS communication and does not allow HTTP connections. If HTTPS is not enabled at the origin, MediaTailor will not sign the request.
+ Your channel must have an origin access policy that includes the following:
  + Principal access for MediaTailor to access your channel. Grant access to **mediatailor.amazonaws.com**.
  + IAM permissions **mediatailor:GetManifest **to read all multivariant playlists referenced by the MediaTailor configuration.

  For information about setting a policy on the channel, see [Create a channel using the MediaTailor console](channel-assembly-creating-channels.md).

**Example origin access policy for Channel Assembly, scoped to the MediaTailor configuration account**  

```
{
    "Effect": "Allow",
    "Principal": {"Service": "mediatailor.amazonaws.com"},
    "Action": "mediatailor:GetManifest",
    "Resource": "arn:aws:mediatailor:us-west-2:777788889999:channel/ca-origin-channel",
    "Condition": {
        "StringEquals": {"AWS:SourceAccount": "777788889999"}
    }
}
```

**Example origin access policy for Channel Assembly, scoped to the MediaTailor playback configuration**  

```
{
    "Effect": "Allow",
    "Principal": {"Service": "mediatailor.amazonaws.com"},
    "Action": "mediatailor:GetManifest",
    "Resource": "arn:aws:mediatailor:us-west-2:777788889999:channel/ca-origin-channel",
    "Condition": {
        "StringEquals": {"AWS:SourceArn": "arn:aws:mediatailor:us-west-2:777788889999:playbackConfiguration/test"}
    }
}
```

## Amazon S3 requirements
<a name="origin-sigv4-s3"></a>

If you use SigV4 to protect your Amazon S3 origin, the following requirements must be met for MediaTailor to access the manifest:
+ The origin base URL in your MediaTailor configuration must be an S3 bucket in the following format: `s3.region.amazonaws.com`
+ Your origin must be configured to use HTTPS. MediaTailor only supports HTTPS communication and does not allow HTTP connections. If HTTPS is not enabled at the origin, MediaTailor will not sign the request.
+ Your channel must have an origin access policy that includes the following:
  + Principal access for MediaTailor to access your bucket. Grant access to **mediatailor.amazonaws.com.** 

    For information about configuring access in IAM, see [Access management](https://docs.aws.amazon.com/) in the *AWS Identity and Access Management User Guide*. 
  + IAM permissions **s3:GetObject **to read all top-level manifests referenced by the MediaTailor configuration.

 For general information about SigV4 for Amazon S3, see the [Authenticating Requests (AWS Signature Version 4)](https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html) topic in the *Amazon S3 API reference*. 

**Example origin access policy for Amazon S3, scoped to the MediaTailor account**  

```
{
    "Effect": "Allow",
    "Principal": {"Service": "mediatailor.amazonaws.com"},
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::mybucket/*",
    "Condition": {
        "StringEquals": {"AWS:SourceAccount": "111122223333"}
    }
}
```

**Example origin access policy for Amazon S3, scoped to the MediaTailor playback configuration**  

```
{
    "Effect": "Allow",
    "Principal": {"Service": "mediatailor.amazonaws.com"},
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::mybucket/*",
    "Condition": {
        "StringEquals": {"AWS:SourceArn": "arn:aws:mediatailor:us-west-2:111122223333:playbackConfiguration/test”}
    }
}
```

## MediaPackage requirements
<a name="origin-sigv4-mp"></a>

If you use SigV4 to protect your MediaPackage v2 origin, the following requirements must be met for MediaTailor to access the manifest:
+ The origin base URL in your MediaTailor configuration must be a MediaPackage v2 endpoint in the following format: `mediapackagev2.region.amazonaws.com`
+ Your origin must be configured to use HTTPS. MediaTailor only supports HTTPS communication and does not allow HTTP connections. If HTTPS is not enabled at the origin, MediaTailor will not sign the request.
+ Your channel must have an origin access policy that includes the following:
  + Principal access for MediaTailor to access your endpoint. Grant access to **mediatailor.amazonaws.com.** 
  + IAM permissions **mediapackagev2:GetObject **to read all multivariant playlists referenced by the MediaTailor configuration.

 For general information about SigV4 for MediaPackage v2, see the [Authenticating Requests (AWS Signature Version 4)](https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html) topic in the *MediaPackage v2 API reference*.

**Example origin access policy for MediaPackage v2, scoped to the MediaTailor account**  

```
{
    "Effect": "Allow",
    "Principal": {"Service": "mediatailor.amazonaws.com"},
    "Action": "mediapackagev2:GetObject",
    "Resource": "arn:aws:mediapackagev2:us-west-2:444455556666:channelGroup/emp-origin-channel-group/channel/emp-origin-channel/originEndpoint/emp-origin-endpoint",
    "Condition": {
        "StringEquals": {"AWS:SourceAccount": "444455556666"}
    }
}
```

**Example origin access policy for MediaPackage v2, scoped to the MediaTailor playback configuration**  

```
{
    "Effect": "Allow",
    "Principal": {"Service": "mediatailor.amazonaws.com"},
    "Action": "mediapackagev2:GetObject",
    "Resource": "arn:aws:mediapackagev2:us-west-2:444455556666:channelGroup/emp-origin-channel-group/channel/emp-origin-channel/originEndpoint/emp-origin-endpoint",
    "Condition": {
        "StringEquals": {"AWS:SourceArn": "arn:aws:mediatailor:us-west-2:444455556666:playbackConfiguration/test”"}
    }
}
```