

# Using AWS Elemental MediaTailor to create linear assembled streams
<a name="channel-assembly"></a>

AWS Elemental MediaTailor channel assembly is a manifest-only service that allows you to create linear streaming channels using your existing video on demand (VOD) content mixed with live content. MediaTailor never touches your content segments, which are served directly from your origin server. Instead, MediaTailor fetches the manifests from your origin, and uses them to assemble a live sliding manifest window that references the underlying content segments. Channel assembly keeps track of things like the media sequence number that's necessary to make playback smooth from asset to asset. Linear assembled streams are created with a low running cost by using existing multi-bitrate encoded and packaged VOD content.

 You can easily monetize channel assembly linear streams by inserting ad breaks in your programs without having to condition the content with SCTE-35 markers. You can use channel assembly with the MediaTailor ad insertion service, or any server-side ad insertion service. 

 To get started with channel assembly, see [Getting started with MediaTailor channel assembly](channel-assembly-getting-started.md). 

For information about integrating Channel Assembly with a content delivery network (CDN), see [Build MediaTailor linear channels with channel assembly and CDN](ca-cdn-wflw.md).

**Topics**
+ [Working with source locations](channel-assembly-source-locations.md)
+ [Working with channels](channel-assembly-channels.md)
+ [Adding a program to a channel's schedule](channel-assembly-programs.md)
+ [Insert personalized ads and ad breaks in a channel stream](channel-assembly-integrating-mediatailor-ssai.md)
+ [Time-shifting a channel's playback](channel-assembly-time-shift.md)

# Working with source locations
<a name="channel-assembly-source-locations"></a>

A source location represents the origin server where your source content is stored. A source location can be Amazon S3, a standard web server, a content delivery network (CDN) such as Amazon CloudFront, or a packaging origin such as AWS Elemental MediaPackage. MediaTailor retrieves your content manifests from the source location, and uses them to assemble your channel's linear stream.

 This topic explains how to use the AWS Elemental MediaTailor console to create and delete source locations, and how to work with VOD sources.

**Topics**
+ [Creating a source location](channel-assembly-creating-source-locations.md)
+ [Configuring authentication for your source location](channel-assembly-source-locations-access-configuration.md)
+ [Working with VOD sources](channel-assembly-working-vod-sources.md)
+ [Working with live sources](channel-assembly-working-live-sources.md)
+ [Using package configurations](channel-assembly-package-configurations.md)
+ [Manifest caching](channel-assembly-manifest-caching.md)

# Creating a source location
<a name="channel-assembly-creating-source-locations"></a>

The following procedure explains how to create a source location using the MediaTailor console. For information about how to create source locations using the MediaTailor API, see [CreateSourceLocation](https://docs.aws.amazon.com/mediatailor/latest/apireference/API_CreateSourceLocation.html) in the *AWS Elemental MediaTailor API Reference*.<a name="create-source-location-procedure"></a>

**To create a source location**

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

1. In the navigation pane, choose **Channel assembly** > **Source locations**.

1. On the navigation bar, choose **Create source location**.

1. Under **Source location configuration**, enter a name and the base URL of your origin server:
   + **Name**: An identifier for your source location, such as **my-origin**.
   + **Base URL**: The protocol and base URL of the origin server your content is stored, such as **https://111111111111.cloudfront.net**. The URL must be in a standard HTTP URL format, prefixed with **http://** or **https://**.

     Optionally select **Use SigV4 for Amazon S3 authentication** if your source location is an Amazon S3 bucket, and if you'd like to use AWS Signature Version 4 for Amazon S3 access authentication. For advanced information, see [Configuring authentication for your source location](channel-assembly-source-locations-access-configuration.md).

1. <a name="access-configuration-console"></a>Under **Access configuration**, optionally configure authentication for your source location:
   + **Access type**: Select the authentication type that MediaTailor uses to access the content stored on the source location's origin. 
     + **SigV4 for Amazon S3** - MediaTailor uses Amazon Signature Version 4 (SigV4) to authorize request to your origin. For more information, see [Authenticating requests to Amazon S3 with SigV4](channel-assembly-access-configuration-sigv4.md).
     + **Secrets Manager access token authentication** - MediaTailor uses Secrets Manager and a AWS KMS customer managed key created, owned, and managed by you to facilitate access token authentication between MediaTailor and your origin. For information about how to configure **Secrets Manager access token authentication**, see [Working with AWS Secrets Manager access token authentication](channel-assembly-access-configuration-access-token.md).
       + **Header name** - Specify a HTTP header name. MediaTailor uses the HTTP header to send the access token to your origin in content manifest requests. You can can use any header name as long as it doesn’t start with `x-amz-` or `x-amzn-`. If you're integrating with [MediaPackage CDN authorization](https://docs.aws.amazon.com/mediapackage/latest/ug/cdn-auth.html), the header value should be `X-MediaPackage-CDNIdentifier`.
       + **Secret string key** - The `SecretString` key that you specified in your Secrets Manager secret. For example, if your `SecretString` contains a key and value pair such as: `{"MyHeaderName": "11111111-2222-3333-4444-111122223333"}`, then `MyHeaderName` is the `SecretString` key you enter in this field.
       + **Secret ARN** - The ARN of the secret that holds your access token. For a step-by-step guide, see [Step 2: Create an AWS Secrets Manager secret](channel-assembly-access-configuration-access-configuring.md#channel-assembly-access-configuration-access-token-how-to-create-secret).

1. Under **Segment delivery server configuration**, optionally configure a server to deliver your content segments:
   + **Use a default segment delivery server**: Enter the base URL of the server that is used to deliver your content segments, such as a CDN. Configure **Default segment host name** if you'd like to use a different server than the source location server to serve the content segments. For example, you can restrict access to the origin manifests from players by using a different CDN configuration for the **Base HTTP URL** (what MediaTailor uses to access the manifests) and the **Default Segment Base URL** (what players uses to access the content segments). If you don't enter a value, MediaTailor defaults to the source location server for segment delivery.
   + **Use named segment delivery servers**: If you have configured a default segment delivery server, you can also configure additional segment delivery servers. Each one must have a unique name and a base URL. The base URL can be a full HTTP URL, or it can be a relative path like `/some/path/` . The names are used to identify which server should be used when MediaTailor receives a request for content segments. If the request contains the header `X-MediaTailor-SegmentDeliveryConfigurationName` and the value of the header matches a name, the corresponding base URL will be used to serve the content. If the header is not included in the request, or if it does not match any names, then the default segment delivery server will be used.

1. Choose **Create source location**.

1. To add more source locations, repeat steps 2-6.

# Configuring authentication for your source location
<a name="channel-assembly-source-locations-access-configuration"></a>

Use **access configuration** to configure authentication for your source location. When access configuration is on, MediaTailor only retrieves source manifests from your origin if the request is authorized between MediaTailor and your origin. Access configuration is turned off by default.

MediaTailor supports the following authentication types:
+ SigV4 for Amazon S3 authentication
+ AWS Secrets Manager access token
+ SigV4 for MediaPackage version 2 (v2) authentication

 This chapter explains how to use SigV4 for Amazon S3, MediaPackage v2, and AWS Secrets Manager access tokens for source location authentication.

 For more information, select the applicable topic.

**Topics**
+ [Authenticating requests to Amazon S3 with SigV4](channel-assembly-access-configuration-sigv4.md)
+ [Working with SigV4 for MediaPackage Version 2](channel-assembly-access-configuration-sigv4-empv2.md)
+ [Working with AWS Secrets Manager access token authentication](channel-assembly-access-configuration-access-token.md)

# Authenticating requests to Amazon S3 with SigV4
<a name="channel-assembly-access-configuration-sigv4"></a>

Signature Version 4 (SigV4) for Amazon S3 is a signing protocol used to authenticate requests to Amazon S3 over HTTPS. When you use SigV4 for Amazon S3, MediaTailor includes a signed authorization header in the HTTPS request to the Amazon S3 bucket used as your origin. If the signed authorization header is valid, your origin fulfills the request. If it isn't valid, the request fails.

 For general information about SigV4 for AWS Key Management Service, 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*. 

**Note**  
MediaTailor always signs requests to these origins with SigV4.

## Requirements
<a name="channel-assembly-access-configuration-sigv4-how-to"></a>

 If you activate SigV4 for Amazon S3 authentication for your source location, you must meet these requirements: 
+ You must allow MediaTailor to access your Amazon S3 bucket by granting **mediatailor.amazonaws.com** principal access in IAM. For information about configuring access in IAM, see [Access management](https://docs.aws.amazon.com/IAM/latest/UserGuide/access.html) in the *AWS Identity and Access Management User Guide*.
+ The **mediatailor.amazonaws.com** service principal must have permissions to read all multivariant playlists referenced by the VOD source package configurations.
+ The caller of the API must have **s3:GetObject** IAM permissions to read all multivariant playlists referenced by your MediaTailor VOD source package configurations.
+ Your MediaTailor source location base URL must follow the Amazon S3 virtual hosted-style request URL format. For example, https://*bucket-name*.s3.*Region*.amazonaws.com/*key-name*. For information about Amazon S3 hosted virtual-style access, see [Virtual Hosted-Style Requests](https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html#virtual-hosted-style-access).

# Working with SigV4 for MediaPackage Version 2
<a name="channel-assembly-access-configuration-sigv4-empv2"></a>

Signature Version 4 (SigV4) for MediaPackage v2 is a signing protocol used to authenticate requests to MediaPackage v2 over HTTP. When you use SigV4 for MediaPackage v2, MediaTailor includes a signed authorization header in the HTTP request to the MediaPackage v2 endpoint used as your origin. If the signed authorization header is valid, your origin fulfills the request. If it isn't valid, the request fails.

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

## Requirements
<a name="channel-assembly-access-configuration-sigv4-empv2-how-to"></a>

 If you activate SigV4 for MediaPackage v2 authentication for your source location, you must meet these requirements: 
+ You must allow MediaTailor to access your MediaPackage v2 endpoint by granting **mediatailor.amazonaws.com** principal access in an Origin Access Policy on the endpoint.
+ Your MediaTailor source location base URL must be a MediaPackage v2 endpoint.
+ The caller of the API must have **mediapackagev2:GetObject** IAM permissions to read all multivariant playlists referenced by the MediaTailor source packaging configurations.

# Working with AWS Secrets Manager access token authentication
<a name="channel-assembly-access-configuration-access-token"></a>

MediaTailor supports *Secrets Manager access token authentication*. With AWS Secrets Manager access token authentication, MediaTailor uses an AWS Key Management Service (AWS KMS) customer managed key and an AWS Secrets Manager secret that you create, own, and manage to authenticate requests to your origin.

In this section, we explain how Secrets Manager access token authentication works, and provide step-by-step information about how to configure Secrets Manager access token authentication. You can work with Secrets Manager access token authentication in the AWS Management Console or programmatically with AWS APIs.

**Topics**
+ [Configuring AWS Secrets Manager access token authentication](channel-assembly-access-configuration-access-configuring.md)
+ [Integrating with MediaPackage endpoints that use CDN authorization](channel-assembly-access-configuration-access-token-integrating-emp-cdn-auth.md)
+ [How MediaTailor Secrets Manager access token authentication works](channel-assembly-access-configuration-overview.md)

# Configuring AWS Secrets Manager access token authentication
<a name="channel-assembly-access-configuration-access-configuring"></a>

When you want to use AWS Secrets Manager access token authentication, you perform the following steps:

1. You [create an AWS Key Management Service customer managed key](https://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html). 

1. You [create a AWS Secrets Manager secret](https://docs.aws.amazon.com/secretsmanager/latest/userguide/managing-secrets.html). The secret contains your access token, which is stored in Secrets Manager as an encrypted secret value. MediaTailor uses the AWS KMS customer managed key to decrypt the secret value.

1. You configure an AWS Elemental MediaTailor source location to use Secrets Manager access token authentication.

The following section provides step-by-step guidance on how to configure AWS Secrets Manager access token authentication.

**Topics**
+ [Step 1: Create an AWS KMS symmetric customer managed key](#channel-assembly-access-configuration-access-token-how-to-create-kms)
+ [Step 2: Create an AWS Secrets Manager secret](#channel-assembly-access-configuration-access-token-how-to-create-secret)
+ [Step 3: Configure a MediaTailor source location with access token authentication](#channel-assembly-access-configuration-access-token-how-to-enable-access-token-auth)

## Step 1: Create an AWS KMS symmetric customer managed key
<a name="channel-assembly-access-configuration-access-token-how-to-create-kms"></a>

You use AWS Secrets Manager to store your access token in the form of a `SecretString` stored in a secret. The `SecretString` is encrypted through the use of an *AWS KMS symmetric customer managed key *that you create, own, and manage. MediaTailor uses the symmetric customer managed key to facilitate access to the secret with a grant, and to encrypt and decrypt the secret value. 

Customer managed keys let you perform tasks such as the following:
+ Establishing and maintaining key policies
+ Establishing and maintaining IAM policies and grants
+ Enabling and disabling key policies
+ Rotating cryptographic key material
+ Adding tags

  For information about how Secrets Manager uses AWS KMS to protect secrets, see the topic [How AWS Secrets Manager uses AWS KMS](https://docs.aws.amazon.com/kms/latest/developerguide/services-secrets-manager.html) in the *AWS Key Management Service Developer Guide*.

  For more information about customer managed keys, see [Customer managed keys](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#customer-cmk) in the *AWS Key Management Service Developer Guide*.

**Note**  
AWS KMS charges apply for using a customer managed key For more information about pricing, see the [AWS Key Management Service Pricing](https://aws.amazon.com/kms/pricing/) page.

You can create an AWS KMS symmetric customer managed key using the AWS Management Console or programmatically with the AWS KMS APIs.

### To create a symmetric customer managed key
<a name="channel-assembly-access-configuration-access-token-create-symmetric-key"></a>

Follow the steps for [Creating a symmetric customer managed key](https://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html#create-symmetric-cmk) in the *AWS Key Management Service Developer Guide.*

Make a note of the key Amazon Resource Name (ARN); you'll need it in [Step 2: Create an AWS Secrets Manager secret](#channel-assembly-access-configuration-access-token-how-to-create-secret).

### Encryption context
<a name="channel-assembly-access-configuration-access-token-encryption-context"></a>

An *encryption context* is an optional set of key-value pairs that contain additional contextual information about the data.

Secrets Manager includes an [encryption context](https://docs.aws.amazon.com/kms/latest/developerguide/services-secrets-manager.html#asm-encryption-context) when encrypting and decrypting the `SecretString`. The encryption context includes the secret ARN, which limits the encryption to that specific secret. As an added measure of security, MediaTailor creates an AWS KMS grant on your behalf. MediaTailor applies a [GrantConstraints](https://docs.aws.amazon.com/kms/latest/APIReference/API_GrantConstraints.html) operation that only allows us to *decrypt* the `SecretString` associated with the secret ARN contained in the Secrets Manager encryption context.

For information about how Secrets Manager uses encryption context, see the [Encryption context ](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#encrypt_context)topic in the *AWS Key Management Service Developer Guide*. 

### Setting the key policy
<a name="channel-assembly-access-configuration-access-token-key-policy"></a>

Key policies control access to your customer managed key. Every customer managed key must have exactly one key policy, which contains statements that determine who can use the key and how they can use it. When you create your customer managed key you can use the default key policy. For more information, see [Authentication and access control for AWS KMS](https://docs.aws.amazon.com/kms/latest/developerguide/control-access.html) in the *AWS Key Management Service Developer Guide*.

To use your customer managed key with your MediaTailor source location resources, you must give permission to the IAM principal that calls [CreateSourceLocation](https://docs.aws.amazon.com/mediatailor/latest/apireference/API_CreateSourceLocation.html) or [UpdateSourceLocation](https://docs.aws.amazon.com/mediatailor/latest/apireference/API_UpdateSourceLocation.html) to use the following API operations:
+ `kms:CreateGrant` – Adds a grant to a customer managed key. MediaTailor creates a grant on your customer managed key that lets it use the key to create or update a source location configured with access token authentication. For more information about using [Grants in AWS KMS](https://docs.aws.amazon.com/kms/latest/developerguide/grants.html), see the *AWS Key Management Service Developer Guide.*

  This allows MediaTailor to do the following:
  + Call `Decrypt` so that it can successfully retrieve your Secrets Manager secret when calling [GetSecretValue](https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_GetSecretValue.html).
  + Call `RetireGrant` to retire the grant when the source location is deleted, or when access to the secret has been revoked.

The following is an example policy statement that you can add for MediaTailor:

```
{
        "Sid": "Enable MediaTailor Channel Assembly access token usage for the MediaTailorManagement IAM role",
        "Effect": "Allow",
        "Principal": {
        "AWS": "arn:aws:iam::account number:role/MediaTailorManagement"
    },
     "Action": "kms:CreateGrant",
     "Resource": "*",
     "Condition": {
         "StringEquals": {
             "kms:ViaService": "mediatailor.region.amazonaws.com"
        }
    }
}
```

For more information about specifying permissions in a policy and troubleshooting key access, see [Grants in AWS KMS](https://docs.aws.amazon.com/kms/latest/developerguide/grants.html) in the *AWS Key Management Service Developer Guide*.

## Step 2: Create an AWS Secrets Manager secret
<a name="channel-assembly-access-configuration-access-token-how-to-create-secret"></a>

Use Secrets Manager to store your access token in the form of a `SecretString` that's encrypted by an AWS KMS customer managed key. MediaTailor uses the key to decrypt the `SecretString`. For information about how Secrets Manager uses AWS KMS to protect secrets, see the topic [How AWS Secrets Manager uses AWS KMS](https://docs.aws.amazon.com/kms/latest/developerguide/services-secrets-manager.html) in the *AWS Key Management Service Developer Guide*.

If you use AWS Elemental MediaPackage as your source location origin, and would like to use MediaTailor Secrets Manager access token authentication follow the procedure [Integrating with MediaPackage endpoints that use CDN authorization](channel-assembly-access-configuration-access-token-integrating-emp-cdn-auth.md).

You can create a Secrets Manager secret using the AWS Management Console or programmatically with the Secrets Manager APIs.

### To create a secret
<a name="channel-assembly-access-configuration-access-token-create-secret"></a>

Follow the steps for [Create and manage secrets with AWS Secrets Manager](https://docs.aws.amazon.com/secretsmanager/latest/userguide/managing-secrets.html) in the *AWS Secrets Manager User Guide*.

Keep in mind the following considerations when creating your secret:
+ The [KmsKeyId](https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_ReplicaRegionType.html#SecretsManager-Type-ReplicaRegionType-KmsKeyId) must be the [key ARN](https://docs.aws.amazon.com/kms/latest/developerguide/find-cmk-id-arn.html) of the customer managed key you created in Step 1.
+ You must supply a [SecretString](https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_CreateSecret.html#SecretsManager-CreateSecret-request-SecretString). The `SecretString` should be a valid JSON object that includes a key and value containing the access token. For example, \$1"MyAccessTokenIdentifier":"112233445566"\$1. The value must between 8-128 characters long.

  When you configure your source location with access token authentication, you specify the `SecretString` key. MediaTailor uses the key to look up and retrieve the access token stored in the `SecretString`.

  Make a note of the secret ARN and the `SecretString` key. You'll use them when you configure your source location to use access token authentication.

### Attaching a resource-based secret policy
<a name="channel-assembly-access-configuration-access-token-secret-policy"></a>

To let MediaTailor access the secret value, you must attach a resource-based policy to the secret. For more information, see [Attach a permissions policy to an Secrets Manager Secret](https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_resource-policies.html) in the *AWS Secrets Manager User Guide*.

The following is a policy statement example that you can add for MediaTailor:

------
#### [ JSON ]

****  

```
{

    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": "mediatailor.amazonaws.com" 
            },
            "Action": "secretsmanager:GetSecretValue",
            "Resource": "arn:aws:secretsmanager:us-east-1:111122223333:secret:secret-name" 
        } 
    ] 

}
```

------

## Step 3: Configure a MediaTailor source location with access token authentication
<a name="channel-assembly-access-configuration-access-token-how-to-enable-access-token-auth"></a>

You can configure Secrets Manager access token authentication using the AWS Management Console or programmatically with the MediaTailor APIs.

**To configure a source location with Secrets Manager access token authentication**

Follow the steps for [Access configuration](channel-assembly-creating-source-locations.md#access-configuration-console) in the *AWS Elemental MediaTailor User Guide*.

# Integrating with MediaPackage endpoints that use CDN authorization
<a name="channel-assembly-access-configuration-access-token-integrating-emp-cdn-auth"></a>

If you use AWS Elemental MediaPackage as your source location origin, MediaTailor can integrate with MediaPackage endpoints that use CDN authorization.

To integrate with a MediaPackage endpoint that uses CDN authorization, use the following procedure.<a name="channel-assembly-access-configuration-access-token-integrating-emp-cdn-auth-procedure"></a>

**To integrate with MediaPackage**

1. Complete the steps in [Setting up CDN authorization](https://docs.aws.amazon.com/mediapackage/latest/ug/cdn-auth-setup.html) in the *AWS Elemental MediaPackage User Guide*, if you haven't already.

1. Complete the procedure in [Step 1: Create an AWS KMS symmetric customer managed key](channel-assembly-access-configuration-access-configuring.md#channel-assembly-access-configuration-access-token-how-to-create-kms).

1. Modify the secret that you created when you set up MediaPackage CDN authorization. Modify the secret with the following values:
   + Update the `KmsKeyId` with the customer managed key ARN that you created in [Step 1: Create an AWS KMS symmetric customer managed key](channel-assembly-access-configuration-access-configuring.md#channel-assembly-access-configuration-access-token-how-to-create-kms). 
   + (Optional) For the `SecretString`, you can either rotate the UUID to a new value, or you can use the existing encrypted secret as long as it's a key and value pair in a standard JSON format, such as `{"MediaPackageCDNIdentifier": "112233445566778899"}`.

1. Complete the steps in [Attaching a resource-based secret policy](channel-assembly-access-configuration-access-configuring.md#channel-assembly-access-configuration-access-token-secret-policy).

1. Complete the steps in [Step 3: Configure a MediaTailor source location with access token authentication](channel-assembly-access-configuration-access-configuring.md#channel-assembly-access-configuration-access-token-how-to-enable-access-token-auth).

# How MediaTailor Secrets Manager access token authentication works
<a name="channel-assembly-access-configuration-overview"></a>

After you create or update a source location to use access token authentication, MediaTailor includes the access token in an HTTP header when requesting source content manifests from your origin.

Here's an overview of how MediaTailor uses Secrets Manager access token authentication for source location origin authentication:

1. When you create or update a MediaTailor source location that uses access token authentication, MediaTailor sends a [DescribeSecret](https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_DescribeSecret.html#SecretsManager-DescribeSecret-request-SecretId) request to Secrets Manager to determine the AWS KMS key associated with the secret. You include the secret ARN in your source location access configuration.

1. MediaTailor creates a [grant](https://docs.aws.amazon.com/kms/latest/developerguide/grants.html) for the customer managed key, so that MediaTailor can use the key to access and decrypt the access token stored in the SecretString. The grant name will be `MediaTailor-SourceLocation-your AWS account ID-source location name`. 

   You can revoke access to the grant, or remove MediaTailor's access to the customer managed key at any time. For more information, see [RevokeGrant](https://docs.aws.amazon.com/kms/latest/APIReference/API_RevokeGrant.html) in the *AWS Key Management Service API Reference*.

1. When a VOD source is created or updated, or used in a program, MediaTailor makes HTTP requests to the source locations to retrieve the source content manifests associated with the VOD sources in the source location. If the VOD source is associated with a source location that has an access token configured, the requests include the access token as an HTTP header value.

# Working with VOD sources
<a name="channel-assembly-working-vod-sources"></a>

A VOD source represents a single piece of content, such as a video or an episode of a podcast, that you add to your source location. You add one or more VOD sources to your source location, and then associate each VOD source with a program after you create your channel.

Each VOD source must have at least one *package configuration*. A package configuration specifies a package format, manifest location, and source group for your VOD source. When you create your channel, you use the package configuration's source groups to create the corresponding outputs on your channel. For example, if your source is packaged in two different formats—HLS and DASH—then you'd create two package configurations, one for DASH and one for HLS. Then, you would create two channel outputs, one for each package configuration. Each channel output provides an endpoint that's used for playback requests. So, using the preceding example, the channel would provide an endpoint for HLS playback requests and an endpoint for DASH playback requests. 

If you would like the offsets of ad markers in your manifest to be detected automatically, each ad marker must appear at the same offset across all package configurations and have a duration of zero. For HLS, MediaTailor will detect `DATERANGE` and` EXT-X-CUE-OUT` tags. For DASH, HLS will detect the first Event tag within each `EventStream` tag.

In the following example, an ad break opportunity will be detected at an offset of 12000ms because of the `DATERANGE` tag with a duration of 0.0. The first `DATERANGE` tag at an offset of 0ms will not be detected because it has a duration of 10.0.

```
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-DATERANGE:ID="1001",START-DATE="2021-09-16T23:51:05.249Z",DURATION=10.0,SCTE35-OUT=0xFC302500000003289800FFF01405000003E97FEFFE1D381BD8FE000DBBA00001010100000FD2B275
#EXTINF:6.000,
../../../719f911124e0495cbb067c91c1d6c298/1785a16ca14d4c2884781f25333f6766/index_1_0.ts
#EXTINF:6.000,
../../../719f911124e0495cbb067c91c1d6c298/1785a16ca14d4c2884781f25333f6766/index_1_1.ts
#EXT-X-DATERANGE:ID="1001",START-DATE="2021-09-16T23:51:05.249Z",DURATION=0.0,SCTE35-OUT=0xFC302500000003289800FFF01405000003E97FEFFE1D381BD8FE000DBBA00001010100000FD2B275
#EXTINF:6.000,
../../../719f911124e0495cbb067c91c1d6c298/1785a16ca14d4c2884781f25333f6766/index_1_2.ts
```

In the following example, an ad break opportunity will be detected at an offset of 0ms because the `EXT-X-CUE-OUT` tag has a duration of 0 and is followed immediately by an `EXT-X-CUE-IN` tag. The second `EXT-X-CUE-OUT`/`EXT-X-CUE-IN` pair will not be detected because it has a duration of 10.

```
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-CUE-OUT:0
#EXT-X-CUE-IN
#EXTINF:6.000,
../../../719f911124e0495cbb067c91c1d6c298/1785a16ca14d4c2884781f25333f6766/index_1_0.ts
#EXTINF:6.000,
../../../719f911124e0495cbb067c91c1d6c298/1785a16ca14d4c2884781f25333f6766/index_1_1.ts
#EXT-X-CUE-OUT:10
...
#EXT-X-CUE-IN
#EXTINF:6.000,
../../../719f911124e0495cbb067c91c1d6c298/1785a16ca14d4c2884781f25333f6766/index_1_2.ts
```

In the following example, an ad break opportunity will be detected at an offset of 0ms because the first Event in the `EventStream` occurs in the period starting at PT0.000S. The second `Event` in the `EventStream` will not be detected.

```
<Period start="PT0.000S" id="9912561" duration="PT29.433S">
<EventStream timescale="90000" schemeIdUri="urn:scte:scte35:2013:xml">
<Event duration="0">
  <scte35:SpliceInfoSection protocolVersion="0" ptsAdjustment="1241950593" tier="4095">
    <scte35:SpliceInsert spliceEventId="99" spliceEventCancelIndicator="false" outOfNetworkIndicator="true" spliceImmediateFlag="false" uniqueProgramId="1" availNum="1" availsExpected="1">
      <scte35:Program><scte35:SpliceTime ptsTime="3552273000"/></scte35:Program>
      <scte35:BreakDuration autoReturn="true" duration="2700000"/>
    </scte35:SpliceInsert>
  </scte35:SpliceInfoSection>
</Event>
<Event duration="0"> 
  <scte35:SpliceInfoSection protocolVersion="0" ptsAdjustment="1241950593" tier="4095">
    <scte35:SpliceInsert spliceEventId="99" spliceEventCancelIndicator="false" outOfNetworkIndicator="true" spliceImmediateFlag="false" uniqueProgramId="1" availNum="1" availsExpected="1">
      <scte35:Program><scte35:SpliceTime ptsTime="3552273000"/></scte35:Program>
      <scte35:BreakDuration autoReturn="true" duration="2700000"/>
    </scte35:SpliceInsert>
  </scte35:SpliceInfoSection>
</Event>
</EventStream>
  ...
</Period>
```

# Adding VOD sources to your source location
<a name="channel-assembly-add-vod-source"></a>

The following procedure explains how to add VOD sources to your source location and set up package configurations using the MediaTailor console. For information about how to add VOD sources using the MediaTailor API, see [CreateVodSource](https://docs.aws.amazon.com/mediatailor/latest/apireference/API_CreateVodSource.html) in the *AWS Elemental MediaTailor API Reference*.

**Important**  
Before you add your VOD sources, make sure that they meet these requirements:   
Source variants must all have the same length, as determined by the source manifest. 
Within a package configuration, each source must have the same number of child streams. 
Because of these requirements, we don't support per title or automated ABR, because these encoding methods can produce varying manifest lengths and child streams.   
We recommend that you use an encoding template that includes a minimum segment length to ensure that your encoded sources meet these requirements.<a name="add-vod-sources-procedure"></a>

**To add VOD sources to your source locations**

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

1. In the navigation pane, choose **Channel assembly** > **Source locations**.

1. In the **Source locations** pane, choose the source location that you created in the [To create a source location](channel-assembly-creating-source-locations.md#create-source-location-procedure) procedure.

1. Choose **Add VOD source**.

1. Under **VOD source details**, enter a name for your VOD source:
   + **Name**: An identifier for your VOD source, such as **my-example-video**. 

1. Under **Package configurations** > *source-group-name* enter information about the package configuration:
**Note**  
Your source's package configurations must all have the same duration, as determined by the source's manifest. And, all of the sources within a package configuration must have the same number of child streams. To meet these requirements, we recommend that you use an encoding template for your assets. We recommend that you use an encoding template with a minimum segment length of one second. MediaTailor doesn't support per title or automated adaptive bitrate streaming (ABR) because these encoding methods violate these requirements.
   + **Source group**: Enter a source group name that describes this package configuration, such as HLS-4k. Make a note of this name; you'll reference it when you create your channel's output. For more information, see [Using source groups with your channel's outputs](channel-assembly-source-groups.md).
   + **Type**: Select the packaged format for this configuration. MediaTailor supports HLS and DASH.
   + **Relative path**: The relative path from the source location's **Base HTTP URL** to the manifest. For example, **/my/path/index.m3u8**.
**Note**  
MediaTailor automatically imports all of the closed captions and child streams contained within a parent multivariant playlist. You don't need to create separate package configurations for each of your sources renditions (DASH) or variant streams (HLS).

    For more information about package configurations, see [Using package configurations](channel-assembly-package-configurations.md). 

1. Choose **Add VOD source**.

   If you want to add more VOD sources, repeat steps 4-7 in the procedure.

# Working with live sources
<a name="channel-assembly-working-live-sources"></a>

A *live source* represents a single live stream, such as a live football game or news broadcast, that you add to your source location. After you create your channel, you add one or more live sources to your source location, and then associate each live source with a program.

MediaTailor supports these types of linear channel assembly:
+ VOD sources for a channel that contains VOD-to-live content
+ Live sources for a channel that contains live-to-live content intermixed with VOD-to-live content

An example of VOD-to-live content is a channel that assembles a library of VOD assets into a live stream. One example of live-to-live content mixed with VOD-to-live content is a channel that shows mostly VOD content, except for a nightly news event or a pre-scheduled live sporting event. Another example of live-to-live content mixed with VOD-to-live content is an all live-to-live channel with origins that vary based on the time of day.

You can use live sources to set up a regional channel that shows mostly national programming, but also includes regioinal programming overrides, and has VOD content mixed in. To do so, you run one encoder/packager pair for the national content, then run regional encoders when those regions are live. Then, you create regional channel-assembly channels, each with their own schedules. This way, viewers can switch back and forth as needed. This setup helps you minimize encoding/packaging costs.

Each live source must have at least one package configuration. A *package configuration* specifies a package format, manifest location, and source group for your live source. When you create your channel, you use the package configuration's source groups to create the corresponding outputs on your channel. For example, if your source is packaged in two different formats—HLS and DASH—then you'd create two package configurations, one for DASH and one for HLS. Then, you'd create two channel outputs, one for each package configuration. Each channel output provides an endpoint that's used for playback requests. In this example, the channel provides an endpoint for HLS playback requests and an endpoint for DASH playback requests.

## General requirements for using live sources
<a name="channel-assembly-live-sources-requirements"></a>

When you use live sources, your content must align with the following general requirements:
+ HLS live sources - You must provide `#EXT-X-PROGRAM-DATE-TIME` tags for the first segment in the manifest window, and on every discontinuity.
+ HLS - You must configure ad markers as `DATERANGE`.
+ Source manifest window - We recommend using a manifest window with a duration that's at least as long as the manifest window on your MediaTailor Channel Assembly channel. As a best practice, consider using a manifest window duration that's 30 seconds or longer than the manifest window on the Channel Assembly channel.
+ Make the target duration match the duration of the existing sources.
+ Make the number of child playlists match that of the existing sources.

## Configurations
<a name="channel-assembly-live-sources-elemental-configuration"></a>

If you use other AWS Elemental media services as part of your live sources workflow, we recommend following best practices when setting up your MediaPackage configuration. The following table describes how to configure MediaPackage settings based on the streaming standard you use.


**MediaPackage setup for live sources**  

|  Standard  |  Setting  |  Value  |  Necessity  |  Notes  | 
| --- | --- | --- | --- | --- | 
|  HLS  |  Endpoint type  |  `Apple HLS`  |  Required unless using CMAF  |  To match HLS `ts` AWS Elemental MediaConvert jobs  | 
|  HLS  |  Endpoint type  |  `CMAF`  |  Required unless using Apple HLS  |  To match HLS `mp4` AWS Elemental MediaConvert jobs  | 
|  HLS  |  `ProgramDateTimeIntervalSeconds`  |  `1`  |  Required  |  You must specify `#EXT-X-PROGRAM-DATE-TIME` on every segment in order to prevent playback issues when there are discontinuities.  | 
|  HLS  |  `PlaylistWindowSeconds`  |  30 seconds longer than the channel assembly manifest window  |  Required  |    | 
|  HLS  |  `AdMarkers`  |  `DATERANGE`  |  Required when passing through ad markers  |    | 
|  HLS  |  `IncludeIframeOnlyStream`  |  Disabled  |  Recommended  |    | 
|  DASH  |  `ManifestLayout`  |  `FULL`  |  Recommended  |    | 
|  DASH  |  `SegmentTemplateFormat`  |  `NUMBER_WITH_TIMELINE` or `TIME_WITH_TIMELINE`  |  Recommended  |  `NUMBER_WITH_DURATION` is not supported.  | 
|  DASH  |  `ManifestWindowSeconds`  |  30 seconds longer than the channel assembly manifest window  |  Required  |    | 
|  DASH  |  `PeriodTriggers`  |  `ADS`  |  Required when passing through ad markers  |    | 

# Adding live sources to your source location
<a name="channel-assembly-add-live-sources"></a>

The following procedure explains how to use the MediaTailor console to add live sources to your source location and set up package configurations. For information about how to add live sources using the MediaTailor API, see [CreateLiveSource](https://docs.aws.amazon.com/mediatailor/latest/apireference/API_CreateLiveSource.html) in the *AWS Elemental MediaTailor API Reference*.

**Important**  
Before you add your live sources, make sure that within a package configuration, each source has the same number of child streams.<a name="add-live-sources-procedure"></a>

**To add live sources to your source locations**

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

1. In the navigation pane, choose **Channel assembly** > **Source locations**.

1. In the **Source locations** pane, choose the source location that you created in the [To create a source location](channel-assembly-creating-source-locations.md#create-source-location-procedure) procedure.

1. On the **Live sources** tab, choose **Add live source**.

1. Under **live source details**, enter a name for your live source:
   + **Name**: An identifier for your live source, such as **my-example-video**. 

1. Under **Package configurations** > *source-group-name* enter information about the package configuration:
**Note**  
Within a package configuration, all of the VOD sources and live sources must have the same number of child streams. We recommend that you configure your source streams the same way.
   + **Source group**: Enter a source group name that describes this package configuration, such as HLS-4k. Make a note of this name; you'll reference it when you create your channel's output. For more information, see [Using source groups with your channel's outputs](channel-assembly-source-groups.md).
   + **Type**: Select the packaged format for this configuration. MediaTailor supports HLS and DASH.
   + **Relative path**: The relative path from the source location's **Base HTTP URL** to the manifest. For example, **/my/path/index.m3u8**.
**Note**  
MediaTailor automatically imports all of the closed captions and child streams contained within a parent multivariant playlist. You don't need to create separate package configurations for each of your sources renditions (DASH) or variant streams (HLS).

    For more information about package configurations, see [Using package configurations](channel-assembly-package-configurations.md). 

1. Choose **Add live source**.

   If you want to add more live sources, repeat steps 4-6 in the procedure.

# Using package configurations
<a name="channel-assembly-package-configurations"></a>

A package configuration is a representation of the source that contains the various packaging characteristics required for playback on different devices. For example, you might have a source that has three packaged formats: HLS with DRM, DASH with segment timeline addressing, and HLS with CMAF segments.

 Channel assembly doesn't repackage your sources. If you want to include multiple packaged formats for a given source, you must make each packaged format available at the source location and specify the path to each packaged format.

 Each package configuration object must include the following: 
+ **Relative path** - The full path to the source's packaged format, relative to the source location. For example, **/my/path/index.m3u8**.
+ **Source group** - The name of the source group used to associate package configurations with a channel's output.
+ **Type** - Either HLS or DASH.

 After you have created a channel, you must also declare each source group that you want to use for the channel's output. 

# Manifest caching
<a name="channel-assembly-manifest-caching"></a>

MediaTailor periodically and opportunistically caches source playlists to improve channel assembly performance and reliability. Sometimes, the cached version becomes stale compared to the origin version at your source location. To force MediaTailor to refresh the cached version of the source, call [UpdateVodSource](https://docs.aws.amazon.com/mediatailor/latest/apireference/API_UpdateVodSource.html). For example, use this call when the embedded paths change in your source. Make sure that you always keep an up-to-date version of the source available on your source location, even if you see few requests from MediaTailor.

# Working with channels
<a name="channel-assembly-channels"></a>

A channel assembles your source manifests into a linear stream. Each channel contains one or more outputs that correspond to your package configurations.

 First you create a channel, then you add your VOD sources and live sources to the channel's schedule by creating *programs*. Each program is associated with a VOD source or a live source.

**Topics**
+ [Create a channel using the MediaTailor console](channel-assembly-creating-channels.md)
+ [Using source groups with your channel's outputs](channel-assembly-source-groups.md)
+ [Delete a channel using the MediaTailor console](channel-assembly-starting-stopping-channels.md)

# Create a channel using the MediaTailor console
<a name="channel-assembly-creating-channels"></a>

 The following procedure describes how to create a channel using the MediaTailor console. <a name="create-channel-procedure"></a>

**To create a channel**

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

1. In the navigation pane, choose **Channel assembly** > **Channels**.

1. On the navigation bar, choose **Create channel**.

1. Under **Channel details**, enter details about your channel:
   + **Name**: Enter a name for your channel.
   + **Tier**: The tier determines what features the channel supports and how much it costs to run the channel. For more information about pricing, see the [Channel Assembly pricing page](https://aws.amazon.com/mediatailor/pricing/#Channel_Assembly_Pricing). MediaTailor supports the following tiers:
     + **Basic** - The Basic tier supports both the Linear and Loop playback modes, and does not support live sources.
     + **Standard** - The Standard tier supports live sources, and requires the Linear playback mode.

       When you select **Standard** in** Channel details**, you can define the audiences under **Audiences details**. These audiences will be used for programRules when you are going to create audienceMedia for your default program..
       + Choose **Add**.
       + Enter the **Audience** name in the text box. It must be between 1 and 32 alphanumeric characters long.
       +  Choose **Confirm**.
       + Choose **Next**.
   + <a name="playback-mode"></a><a name="playback-mode.title"></a>**Playback mode**: The playback mode sets the channel's playback behavior. MediaTailor supports the following playback modes:
     + **Loop** - The programs in the schedule play back-to-back in an endless loop. After the last program plays in a schedule, playback loops back to the first program. Playback continues looping until you stop the channel.
     + **Linear** - Each program in the schedule plays once, back-to-back.

1. <a name="filler-slate"></a>For **Filler slate**, select the **Source location name** referencing the slate location, and the **VOD source name** to use as slate. MediaTailor uses the slate to fill gaps between programs in the schedule. If the duration of the slate is less than the duration of the gap between programs, MediaTailor loops the slate. You must configure filler slate field is if your channel uses the linear playback mode. MediaTailor doesn't support filler slate for the loop playback mode.

1. Choose **Next**.

1. Specify audience details under program rules.

1. When you select **Standard** in** Channel details**, you can define the audiences under **Audiences** details. These audiences will be used for **programRules** when you are going to create **audienceMedia** for your default program:
   + Select **Add**, and then add an Audience in the text box, then select **Confirm**.
**Note**  
Enter a name that's no longer than\$1 32 alphanumeric characters.
   + **Output type**: Select the streaming format for the channel. DASH and HLS are supported.
   + **Source group**: Enter the name of the source group that you created in your package configuration, as described in [Adding VOD sources to your source location](channel-assembly-add-vod-source.md).

1. Select **Next**.

1. Under **Manifest settings**, enter additional information about your manifest settings:
   + **Manifest window (sec)**: The time window,in seconds, contained in each manifest. The minimum value is 30 seconds, and the maximum value is 3600 seconds.
   + **Ad markup type(HLS outputs only)**: The type of ad tags that appear in VOD program ad breaks. Select `Daterange` to have MediaTailor insert ad breaks into VOD programs with `EXT-X-DATERANGE` tags. Select `Scte35 Enhanced` to have MediaTailor insert ad breaks into VOD programs using `EXT-X-CUE-OUT` and `EXT-X-CUE-IN` tags. For more information about these tag types, see [SCTE-35 messages for ad breaks](ca-scte-35-messages.md). For live workflows, MediaTailor always passes through `DATERANGE` tags, and doesn't pass through any Enhanced Scte35 tags, regardless of the selected Ad markup type.

1. If you want to configure multiple channel outputs, under **Outputs** choose **Add**. Then, configure the details for your output by completing the steps 6 and 7 in this procedure.

1. Choose **Next**.

1. Under **Channel policy**, choose your channel's IAM policy settings:
   + **Do not attach channel policy**: Restrict playback to only those who have access to this account's credentials.
   + **Attach custom policy**: Define your own policy and restrict access to as few or as many as you want. 
   + **Attach public policy**: Accept all incoming client requests to a channel's output. You must use this option if you want to use MediaTailor ad insertion.

1. Choose **Next**.

1. Review your settings on the **Review and create** pane.

1. Choose **Create channel**.
**Note**  
Channels are created in a stopped state. Your channel won't be active until you start it with the MediaTailor console or the MediaTailor StartChannel API.

# Using source groups with your channel's outputs
<a name="channel-assembly-source-groups"></a>

A source group associates a package configuration with an output on a channel. When you create the package configuration on the source, you identify the source group's name. Then, when you create the output on the channel, you enter that same name to associate the output with the package configuration. VOD sources and live sources that are added to a program on a channel must belong to the source group that's identified in the output.

 For example:
+ VOD sources 1 and 2 both have three package configurations that have the source groups: **HLS**, **DASH**, and **HLS-4k**.
+ VOD source 3 has two package configurations with source groups **HLS** and **DASH**.





 If channel A has two outputs with source groups **HLS** and **DASH**, the channel output can use all three VOD sources. That's because VOD sources 1, 2, and 3 all have package configurations with source group labels **HLS** and **DASH**.

If channel B has two outputs with source groups **HLS** and **HLS-4k**, it can use VOD source 1 and 2, but not 3. This is because VOD sources 1 and 2 both have package configurations with source group labels **HLS** and **HLS-4k**.

If channel C has a single output with the source group **DASH**, it can use all three VOD sources. All three VOD sources have package configurations with the **DASH** source group.

# Delete a channel using the MediaTailor console
<a name="channel-assembly-starting-stopping-channels"></a>

 To delete your channel, complete the following procedure. <a name="delete-channel"></a>

**To delete your channel**

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

1. In the navigation pane, choose **Channel assembly** > **Channels**.

1. Select the channel that you want to delete.

1. If your channel is running, from the **Actions** drop-down menu, choose **Stop**. You must stop your channel before you can delete it.

1. When your channel is stopped, from the **Actions** drop-down menu, choose **Delete**.

# Adding a program to a channel's schedule
<a name="channel-assembly-programs"></a>

Each program contains a VOD source or a live source that's part of a source location in your account. You add your programs to your channel's schedule to control the order that they play in your channel's stream.

A program that contains a VOD source can be configured with one or more ad breaks. Each ad break contains a slate, which is a VOD source from a source location. To create the ad break, you add the slate at an offset in milliseconds into the program.

**Topics**
+ [Creating a program within a channel schedule using the MediaTailor console](channel-assembly-adding-programs.md)
+ [Defining audience cohorts and alternate content with Program Rules](working-with-program-rules.md)
+ [Generating audience-specific manifests](generating-audience-specific-manifests.md)

# Creating a program within a channel schedule using the MediaTailor console
<a name="channel-assembly-adding-programs"></a>

 The following procedure describes how to create a program within your channel's schedule using the MediaTailor console. It also describes how to configure ad breaks, which are optional. For information about how to create programs using the MediaTailor API, see [CreateProgram](https://docs.aws.amazon.com/mediatailor/latest/apireference/API_CreateProgram.html) in the *AWS Elemental MediaTailor API Reference*. <a name="add-programs-procedure"></a>

**To add a program**

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

1. In the navigation pane, choose **Channel assembly** > **Channels**.

1. In the **Channels** pane, choose the channel that you created in the [To create a channel](channel-assembly-creating-channels.md#create-channel-procedure) procedure.

1. In the **Program details** enter details about your program:
   + **Name**: This is the name of the program that you add to your channel.
   + **Source type**: Determines what type of source video the program plays. This option is only available for Standard channels.
     + **VOD** - The program plays a video-on-demand source, such as a pre-recorded TV episode.
     + **Live** - The program plays a live source, such as a live news broadcast.
   + **Source location name**: The source location that MediaTailor associates with the program.
     + If you choose **Select an existing source location**, choose a sourcelocation name from the** Select a source location** menu. Alternatively, search for your source location by name. This is helpful if you have a large number of source locations.
     + If you choose **Enter the source location name**, search for your source location by name.
     + **VOD source name**: The name of the VOD source that MediaTailor associates with the program:
       + If you choose** Select an existing VOD source**, select a VOD source name from the list of VOD sources that are associated with your account. Alternatively, search for your VOD source by name. This is helpful if you have a large number of VOD sources.
       + If you choose **Search by name**, search for your live source by name.
     + **Live source name**: The name of the live source to be associated with the program. This option is only available if you selected **Live** as the source type.
       + If you choose **Select an existing source location**, choose a sourcelocation name from the** Select a source location** menu. Alternatively, search for your source location by name. This is helpful if you have a large number of source locations.
       + If you choose **Enter the source location name**, search for your source location by name.
       + **VOD source name**: The name of the VOD source that MediaTailor associates with the program:
         + If you choose **Select an existing live source**,select a live source name from the list of live sources that are associated with your account. You can alternatively search for your live source by name. This is helpful if you have a large number of live sources.
         + If you choose **Search by name**, search for your live source by name.

1. Select **Next** to go to the ** Schedule Configuration **tab.

1. Under **Playback configuration**, define when a program plays in your channel's schedule:
   + **Duration in milliseconds**: Defines the duration of the program in milliseconds. This option is only available for programs that use live sources.
   + **Transition type**: Defines the transitions from program to program in the schedule:
     + **Relative**: The program plays either before or after another program in the schedule. This option is only available for programs that use VOD sources.
     + **Absolute**: The program plays at a specific wall-clock time. MediaTailor makes a best effort to play the program at the clock time that you specify. MediaTailor starts playback of the program on a common segment boundary between the preceding program or slate. This option is only available for channels configured to use the linear [**Playback mode**: The playback mode sets the channel's playback behavior. MediaTailor supports the following playback modes:](channel-assembly-creating-channels.md#playback-mode).
     + **Program start time**: For absolute transition types, the wall-clock time when the program is scheduled to play. If you are adding this program to a running linear channel, you must enter a start time that's 15 minutes or later from the current time.
     + **Relative position**: Choose where to insert the program into the schedule, relative to another program. You can select **Before program** or **After program**. This setting does not apply if this is the first program in your channel's schedule.
       + If you choose **Select an existing program**, select the program name from a predefined list of the next 100 programs played by the channel from the **Use existing program** menu.
       + If you choose **Search for a program by name**, enter the name of an existing program in your channel.

   If you'd like to add ad breaks to your program, continue to the next step. Ad breaks are only configurable for programs that use VOD sources. For live sources, ad breaks in DASH manifests and ad breaks in HLS manifests that use the `EXT-X-DATERANGE` tag are passed through automatically.

1. Select **Next** to go to **Add ad breaks**.

1. Select **Add ad break**. Under **Ad breaks**, configure the settings for the ad break:
   + **Slate source location name**: Choose **Select an existing source location** and choose the source location where your slate is stored that you created earlier in this task.
   + **VOD source name**: Choose **Select an existing VOD source** and choose the VOD source you're using for slate that you added earlier in this task. The duration of the slate determines the duration of the ad break.
   + **Offset in milliseconds**: This value determines the ad break start time in milliseconds, as an offset relative to the beginning of the program. Enter any value that's less than the duration of the VOD source, and that aligns with a segment boundary on all tracks within the program's VOD source (all audio, video and closed caption tracks), otherwise the ad break will be skipped. For example, if you enter **0**, this creates a pre-roll ad break that plays before the program begins.
   + **Avail number**: MediaTailor writes this value is written to `splice_insert.avail_num`, as defined in section 9.7.3.1. of the SCTE-35 specification, [Digital Program Insertion Cueing Message](https://webstore.ansi.org/Standards/SCTE/ANSISCTE352022). The default value is 0. Values have to be between 0 and 256, inclusive.
   + **Avail expected**: MediaTailor writes this value to `splice_insert.avails_expected`, as defined in section 9.7.3.1. of the SCTE-35 specification. The default value is 0. Values have to be between 0 and 256, inclusive.
   + **Splice event ID**: MediaTailor writes this value to `splice_insert.splice_event_id`, as defined in section 9.7.3.1. of the SCTE-35 specification. The default value is 1.
   + **Unique program ID**: MediaTailor writes this value to `splice_insert.unique_program_id`, as defined in section 9.7.3.1. of the SCTE-35 specification. The default value is 0. Values have to be between 0 and 256, inclusive.

1. For a Standard Linear Channel, select **Next** to go to **Set alternate media**.

   For more information on using MediaTailor to create alternate media, see [Creating alternate media](working-with-program-rules.md#program-rules-creating-alternate-media).

   For more advanced information on using MediaTailor to personalize your ad breaks, see [Insert personalized ads and ad breaks in a channel stream](channel-assembly-integrating-mediatailor-ssai.md).

1. Select **Next** to go to **Review and create**.

1. Select **Add program**.

   For more advanced information on using MediaTailor to personalize your ad breaks, see [Insert personalized ads and ad breaks in a channel stream](channel-assembly-integrating-mediatailor-ssai.md).

1. 
**Important**  
For looping channels, if you modify the program list for a program that is scheduled within the next 10 minutes, the edit won't become apparent until the next loop.

   Under **Program details**, enter details about your program:
   + **Name**: This is the name of the program that you add to your channel.
   + **Source type**: Determines what type of source the program plays. This option is only available for Standard channels.
     + **VOD** - The program plays a VOD source, such as a pre-recorded TV episode.
     + **Live** - The program plays a live source, such as a live news broadcast.
   + **Source location name**: The source location to be associated with the program.

     If you choose **Select an existing source location**, select a source location name from the **Select a source location** drop-down menu. You can alternatively search for your source location by name. This is helpful if you have a large number of source locations.

     If you choose **Enter the source location name**, search for your source location by name.
   + **VOD source name**: The name of the VOD source to be associated with the program.

     If you choose **Select an existing VOD source**, select a VOD source name from the list of VOD sources that are associated with your account. You can alternatively search for your VOD source by name. This is helpful if you have a large number of VOD sources.

     If you choose **Search by name**, search for your VOD source by name.
   + **Live source name**: The name of the live source to be associated with the program. This option is only available if you selected **Live** as the source type.

     If you choose **Select an existing live source**, select a live source name from the list of live sources that are associated with your account. You can alternatively search for your live source by name. This is helpful if you have a large number of live sources.

     If you choose **Search by name**, search for your live source by name.

1. Under **Playback configuration**, define when a program plays in your channel's schedule:
   + **Duration in milliseconds**: Defines the duration of the program in milliseconds. This option is only available for programs that use live sources.
   + **Transition type**: Defines the transitions from program to program in the schedule.
     + **Relative** - The program plays either before or after another program in the schedule. This option is only available for programs that use VOD sources.
     + **Absolute** - The program plays at a specific wall clock time. MediaTailor makes a best effort to play the program at the clock time that you specify. We start playback of the program on a common segment boundary between the preceding program or slate. This option is only available for channels configured to use the [linear playback mode](channel-assembly-creating-channels.md#linear-playback-mode).
**Note**  
Be aware of the following behavior for absolute transition types:  
If the preceding program in the schedule has a duration that extends beyond the wall clock time, MediaTailor truncates the preceding program on the common segment boundary closest to the wall clock time.
If there are gaps between programs in the schedule, MediaTailor plays [filler slate](channel-assembly-creating-channels.md#filler-slate). If the duration of the slate is less than the duration of the gap, MediaTailor loops the slate.
   + **Program start time** - For absolute transition types, the wall clock time when the program is scheduled to play. If you are adding this program to a running linear channel, you must enter a start time that's 15 minutes or later from the current time.
   + **Relative position**: Choose where to insert the program into schedule relative to another program. You can select **Before program** or **After program**. This setting does not apply if this is the first program in your channel's schedule.
   + **Relative program**: The name of the program to be used to insert the new program before or after. This setting does not apply if this is the first program in your channel's schedule.

     If you choose **Select an existing program**, select the program name from a predefined list of the next 100 programs played by the channel in the **Use existing program** drop-down menu.

     If you choose **Search for a program by name**, enter name of an existing program in your channel.

   If you'd like to add ad breaks to your program, continue to the next step. Ad breaks are only configurable for programs that use VOD sources. For live sources, ad breaks in DASH manifests and ad breaks in HLS manifests that use the `EXT-X-DATERANGE` tag are passed through automatically.

1. Select **Add ad break**. Under **Ad breaks**, configure the settings for the ad break:<a name="channel-assembly-programs-ad-breaks"></a>
   + **Slate source location name**: Choose **Select an existing source location** and choose the source location where your slate is stored that you created earlier in this tutorial.
   + **VOD source name**: Choose **Select an existing VOD source** and choose the VOD source you're using for slate that you added earlier in this tutorial. The duration of the slate determines the duration of the ad break.
   + For **Offset in milliseconds**: This value determines the ad break start time in milliseconds, as an offset relative to the beginning of the program. Enter any value that's less than the duration of the VOD source, and that aligns with a segment boundary on all tracks within the program's VOD source (all audio, video and closed caption tracks), otherwise the ad break will be skipped. For example, if you enter **0**, this creates a pre-roll ad break that plays before the program begins.
**Note**  
If MediaTailor detects ad markers, such as`DATERANGE` or `EXT-X-CUE-OUT` for HLS and `EventStream` for DASH, with durations of zero within your VOD source, you can select the offset of those ad markers from the drop-down menu to be used as the ad break’s offset. In order for an ad opportunity to be detected, it must be present at the same offset across all package configurations within a VOD source, and its duration must be zero.
   + **Message type**: The SCTE-35 ad insertion type. Choose either **SPLICE\$1INSERT** or **TIME\$1SIGNAL**:
     + **SPLICE\$1INSERT**: Provides basic metadata about the ad break using splice insert parameters.
     + **TIME\$1SIGNAL**: Provides more advanced metadata using segmentation descriptors. For more information about the differences between message types, see [SCTE-35 messages for ad breaks](ca-scte-35-messages.md).

     For **SPLICE\$1INSERT** message type:
     + For **Avail number**, this is written to `splice_insert.avail_num`, as defined in section 9.7.3.1. of the SCTE-35 specification. The default value is `0`. Values have to be between `0` and `256`, inclusive.
     + For **Avail expected**, this is written to `splice_insert.avails_expected`, as defined in section 9.7.3.1. of the SCTE-35 specification. The default value is `0`. Values have to be between `0` and `256`, inclusive.
     + For **Splice event ID**, this is written to `splice_insert.splice_event_id`, as defined in section 9.7.3.1. of the SCTE-35 specification. The default value is `1`.
     + For **Unique program ID**, this is written to `splice_insert.unique_program_id`, as defined in section 9.7.3.1. of the SCTE-35 specification. The default value is `0`. Values have to be between `0` and `256`, inclusive.

     For **TIME\$1SIGNAL** message type:
     + For **Segmentation event ID**, this is written to `segmentation_descriptor.segmentation_event_id`, as defined in section 10.3.3.1 of the SCTE-35 specification. The default value is `1`.
     + For **Segmentation type ID**, this is written to `segmentation_descriptor.segmentation_type_id`, as defined in section 10.3.3.1 of the SCTE-35 specification. The default value is `48` (0x30). Values have to be between `0` and `256`, inclusive.
     + For **Segmentation UPID**, this is written to `segmentation_descriptor.segmentation_upid`, as defined in section 10.3.3.1 of the SCTE-35 specification. The value must be a hexadecimal string containing characters `0-9` and `A-F`. The default value is an empty string.
     + For **Segmentation UPID type**, this is written to `segmentation_descriptor.segmentation_upid_type`, as defined in section 10.3.3.1 of the SCTE-35 specification. The default value is `14` (0x0E). Values have to be between `0` and `256`, inclusive.
     + For **Segment number**, this is written to `segmentation_descriptor.segment_num`, as defined in section 10.3.3.1 of the SCTE-35 specification. The default value is `0`. Values have to be between `0` and `256`, inclusive.
     + For **Segments expected**, this is written to `segmentation_descriptor.segments_expected`, as defined in section 10.3.3.1 of the SCTE-35 specification. The default value is `0`. Values have to be between `0` and `256`, inclusive.

1. Choose **Add program**.

    For more advanced information using MediaTailor to personalize your ad breaks, see [Insert personalized ads and ad breaks in a channel stream](channel-assembly-integrating-mediatailor-ssai.md).
**Note**  
If your channel has at least one output with an `Enhanced Scte35` Ad markup type, you can submit ad-break metadata. MediaTailor writes the submitted key-value pairs to the `EXT-X-ASSET` tag for your ad break.

# Defining audience cohorts and alternate content with Program Rules
<a name="working-with-program-rules"></a>

With Program Rules, you can define audience cohorts for a channel and specify alternate media to play for those audiences. You can associate one or more alternate content sources with an audience for a program. After the program ends, the default audience content will play unless you specify further alternate media.

Program Rules are available on STANDARD tier channels with the LINEAR playback mode. MediaTailor channels support alternate media for all VOD sources and live sources.

For an example use, see [ Using program rules with AWS MediaTailor](https://aws.amazon.com/blogs/media/using-program-rules-with-aws-elemental-mediatailor/).

## Defining audiences
<a name="defining-audiences-program-rules"></a>

Define audiences on a channel by typing audience one by one when configuring a MediaTailor channel. You can do this through either the MediaTailor console or the MediaTailor `CreateChannel` API. Each audience must be between 1 and 32 alphanumeric characters long. If the values provided for the audiences are invalid, then the request fails.

You can only define audiences on STANDARD tier channels with the LINEAR playback mode.

When you need to update the audiences, you can do this using either the MediaTailor console or the MediaTailor `UpdateChannel` API.

If you are using the `ProgramRules` feature, make sure that the `AudienceMedia` defined in `CreateProgram` or `UpdateProgram` request contain the existing audience defined in the channel.

## Creating alternate media
<a name="program-rules-creating-alternate-media"></a>

The following task explains how to define alternate media using the MediaTailor console. For information about how to define alternate media using the MediaTailor API, see [https://docs.aws.amazon.com/mediatailor/latest/apireference/API_CreateProgram.html](https://docs.aws.amazon.com/mediatailor/latest/apireference/API_CreateProgram.html) in the *AWS Elemental MediaTailor API Reference*.

To define alternate media on a new program:

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

1. In the navigation pane, select **Channel assembly** > **Channels**.

1. Select the channel name to which you want to add alternate media.

1. Create a program. For more information, see [Creating a program within a channel schedule using the MediaTailor console](channel-assembly-adding-programs.md).

1. Configure alternate media:
   + Select **Add** in the **Audiences** box to select the audience for which you are defining alternate media.
   + Select an audience defined on the channel from the **Audience** menu.
   + Select **Add alternate media** to begin defining alternate media for the program.
   + MediaTailor creates an ** Alternate media 1** box. This is the first content that MediaTailor plays as alternate media on the program.
   + Within the** Alternate media 1** box:
     + Select a **Source Location**.
     + Select either a **VOD** or** Live ** Source Type:

       For VOD
       + Select VOD for the **Source Type**.
       + (Optional) specify a **Clip Range**. With VOD Sources, including alternate-media VOD sources, you can specify a portion of a VOD source to play, clipping from the start and/or the end of the source. Specify The start and end offsets are in milliseconds.
       + (Optional) a\$1Add Ad Breaks. This is done in the same way as when creating programs. For more information, see [Creating a program within a channel schedule using the MediaTailor console](channel-assembly-adding-programs.md).

       For Live
       + Select Live for the** Source Type**.
       + Select a **Live source**.
       + Enter a **Start time** in milliseconds of the wal-clock time that this live source should start. The live source will only play within the time frame of the default program it is being defined on. If the start time is prior to the start of the default program, it will not begin until the default program does. If the start time is after the default program ends, MediaTailor will not play the live source.
       + Enter a **Duration** in milliseconds. The duration must be at least 10 minutes in length.
       + Additional alternate media can be added to this program for the audience by selecting **Add alternate media** again. This will create another box labeled **Alternate media 2**. You can specify upp to 5 alternate-media sources per program, per audience.
       + Once you are finished defining alternate media for all desired audiences, select **Next** and continue creating the program.

         For more information, see [Creating a program within a channel schedule using the MediaTailor console](channel-assembly-adding-programs.md).
**Note**  
Alternate media only plays in the time frame of the program it is defined on. If all the alternate content overruns the default content, MediaTailor will truncate it. MediaTailor plays alternate media in the order in which it is defined. Live alternate-media start times will always take precedence and will truncate previously scheduled VOD sources or live sources. Any time that is not filled with alternate media for an audience will be filled withe the channel-defined filler slate
   + To define audience media for other audiences, select **Add** once again next to **Audiences**. Select the newly created audience, set the audience id and add alternate media as described above. Up to 5 audiences can have alternate media on any one program.

# Generating audience-specific manifests
<a name="generating-audience-specific-manifests"></a>

To retrieve a manifest for a particular audience, use the `aws.mediatailor.channel.audienceId` query parameter. This query parameter may be dynamically appended by your CDN or added through a call to your content or customer-management system. You must maintain the association of a given playback session to an `audienceId` outside of MediaTailor. This will retrieve an audience-specific manifest with any alternate media defined for that audience in place of default content. It is important that once a manifest is requested for a particular audience that the player always requests the manifest with that same audience ID or there could be playback errors.

If a request is made for an audience that does not exist on the channel, MediaTailor returns a 404 error.

**Example Getting a manifest for an audience**  
`https:// prefix>.channel-assembly.mediatailor.us-west-2.amazonaws.com/v1/channel/ExampleChannel/index_dash.mpd?aws.mediatailor.channel.audienceId=Seattle`

# Insert personalized ads and ad breaks in a channel stream
<a name="channel-assembly-integrating-mediatailor-ssai"></a>

With MediaTailor, you can monetize channel assembly linear streams by inserting ad breaks in your programs without conditioning the content with SCTE-35 markers. You can use channel assembly with the MediaTailor ad insertion service, or with any server-side ad insertion (SSAI).

The following topics show how to insert personalized ads and ad breaks in your channel's linear stream.

**Topics**
+ [Setting up ad insertion with MediaTailor](ca-setting-up-emt-ssai.topic.md)
+ [SCTE-35 messages for ad breaks](ca-scte-35-messages.md)

# Setting up ad insertion with MediaTailor
<a name="ca-setting-up-emt-ssai.topic"></a>

To insert personalized ads into your channel's stream, your channel's endpoint URL is the content source for AWS Elemental MediaTailor. This guide shows how to set up MediaTailor for ad insertion.

## Prerequisites
<a name="ca-setting-up-emt-ssai-prereqs"></a>

Before you begin, make sure that you meet the following requirements:
+ Prepare your HLS and DASH streams for MediaTailor ad insertion. 
  + If you haven't prepared content streams already, see [Step 2: Prepare a stream](getting-started-ad-insertion.md#getting-started-prep-stream) in the *Getting started with MediaTailor ad insertion* topic.
+ Have an ad decision server (ADS).
+ Configure **Ad break** settings in the program. For more information, see the [Configuring ad breaks for your program](channel-assembly-adding-programs.md#channel-assembly-programs-ad-breaks) procedure.<a name="considerations"></a>

As a best practice, consider using a content delivery network (CDN) in between channel assembly and MediaTailor ad insertion. The MediaTailor ad insertion service can generate additional origin requests. Therefore, it's a best practice to configure your CDN to proxy the manifests from channel assembly, then use the CDN prefixed URLs at the content source URL.

## Configure MediaTailor for ad insertion
<a name="name"></a>

The following shows how to configure MediaTailor console settings so that you can insert personalized ads into your channel's stream.<a name="ca-integrating-ssai-procedure"></a>

**To configure MediaTailor for ad insertion**

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

1. In the navigation pane, choose **Configurations**.

1. Under **Required settings**, enter the basic required information about your configuration:
   + **Name**: The name of your configuration.
   + **Content source**: Enter the playback URL from your channel's output, minus the file name and extension. For advanced information about MediaTailor configuration, see [Required settings](configurations-create.md#configurations-create-main).
   + **Ad decision server**: Enter the URL for your ADS.

1. You can optionally configure the **Configuration aliases**, **Personalization details**, and **Advanced settings**. For information about those settings, see [Optional configuration settings](configurations-create.md#configurations-create-addl).

1. On the navigation bar, choose **Create configuration**.

Now that you've set up MediaTailor for ad insertion, you can also set up ad breaks. For detailed instructions, see [Getting started with MediaTailor ad insertion](getting-started-ad-insertion.md).

# SCTE-35 messages for ad breaks
<a name="ca-scte-35-messages"></a>

With MediaTailor, you can create a content channel based off of source location and VOD source resources. You can then set up one or more ad breaks for each of the programs on a channel's schedule. You use messages based on the SCTE-35 specification to condition the content for ad breaks. For example, you can use SCTE-35 messages to provide metadata about the ad breaks. For more information about the SCTE-35 specification, see [Digital Program Insertion Cueing Message](https://webstore.ansi.org/Standards/SCTE/ANSISCTE352022).

You set up the ad breaks in one of two ways:
+ Attaching a `time_signal` SCTE-35 message with a `segmentation_descriptor` message. This `segmentation_descriptor` message contains more advanced metadata fields, like content identifiers, which convey more information about the ad break. MediaTailor writes the ad metadata to the output manifest as part of the `EXT-X-DATERANGE` (HLS) or `EventStream` (DASH) ad marker's SCTE-35 data.
+ Attaching a `splice_insert` SCTE-35 message that provides basic metadata about the ad break.
+ HLS:
  + When the Ad markup type is `Daterange`, MediaTailor specifies ad breaks as `EXT-X-DATERANGE` tags in the manifest.
  + When the Ad markup type is `Scte35 Enhanced`, MediaTailor specifies ad breaks using the following tags:
    + MediaTailor places an `EXT-X-CUE-OUT` on the first segment of the ad slate, indicating a cut from content to the ad break. It contains the expected duration of ad break, such as `EXT-X-CUE-OUT:Duration=30`.
    + `>EXT-X-ASSET`: This tag appears on the same segment as `EXT-X-CUE-OUT` and contains the ad-break metadata supplied in the AdBreak when the program is created or updated. It always contains `CAID`.
    + `EXT-OATCLS-SCTE35`: This tag appears on the same segment as `EXT-X-CUE-OUT` and contains base64-encoded bytes of the SCTE-35 message.
    + `EXT-X-CUE-OUT-CONT`: This tag appears on each subsequent segment within the ad slate, and contains duration and elapsed-time information. It also contains the base64-encoded SCTE-35 message, and the `CAID`.
    + `EXT-X-CUE-IN`: This tag appears on the first segment of content after the ad break is over, and indicates a cut from an ad break back to content.

The following illustration shows the two ways of setting up ad breaks in a channel using SCTE-35 messages:
+ Use a `splice_insert()` message to set up ad breaks with basic metadata.
+ Use a `time_signal()` message together with a `segmentation_descriptor()` message to set up ad breaks with more detailed metadata.

![\[Two ways of setting up ad breaks in a channel using SCTE-35 messages.\]](http://docs.aws.amazon.com/mediatailor/latest/ug/images/scte-35-splice-insert-vs-time-signal-segmentation-descriptor.png)


For information about using `time_signal`, see section 9.7.4 of the 2022 SCTE-35 specification, [Digital Program Insertion Cueing Message](https://webstore.ansi.org/Standards/SCTE/ANSISCTE352022).

The ad break information appears in the output `splice_info_section` SCTE-35 data. With MediaTailor, you can pair a single `segmentation_descriptor` message together with a single `time_signal` message.

**Note**  
If you send a `segmentation_descriptor` message, you must send it as part of the `time_signal` message type. The `time_signal` message contains only the `splice_time` field that MediaTailor constructs using a given timestamp.

The following table describes the fields that MediaTailor requires for each `segmentation_descriptor` message. For more information, see section 10.3.3.1 of the 2022 SCTE-35 specification, which you can purchased at the [ANSI Webstore website](https://webstore.ansi.org/Standards/SCTE/ANSISCTE352022).


**Required fields for a `segmentation_descriptor` message**  

| Field | Type | Default value | Description | 
| --- | --- | --- | --- | 
| segmentation\$1event\$1id | integer | 1 | This is written to segmentation\$1descriptor.segmentation\$1event\$1id. | 
| segmentation\$1upid\$1type | integer | 14 (0x0E) | This is written to segmentation\$1descriptor.segmentation\$1upid\$1type. The value must be between 0 and 256, inclusive. | 
| segmentation\$1upid | string | "" (empty string) | This is written to segmentation\$1descriptor.segmentation\$1upid. The value must be a hexadecimal string, containing characters 0-9 and A-F. | 
| segmentation\$1type\$1id | integer | 48 (0x30) | This is written to segmentation\$1descriptor.segmentation\$1type\$1id. The value must be between 0 and 256, inclusive. | 
| segment\$1num | integer | 0 | This is written to segmentation\$1descriptor.segment\$1num. The value must be between 0 and 256, inclusive. | 
| segments\$1expected | integer | 0 | This is written to segmentation\$1descriptor.segments\$1expected. The value must be between 0 and 256, inclusive. | 
| sub\$1segment\$1num | integer | null | This is written to segmentation\$1descriptor.sub\$1segment\$1num. The value must be between 0 and 256, inclusive. | 
| sub\$1segments\$1expected | integer | null | This is written to segmentation\$1descriptor.sub\$1segments\$1expected. The value must be between 0 and 256, inclusive. | 

The following table shows the values that MediaTailor automatically sets for some of the `segmentation_descriptor` message's fields.


**Values set by MediaTailor for a `segmentation_descriptor` message's fields**  

| Field | Type | Value | 
| --- | --- | --- | 
| segmentation\$1event\$1cancel\$1indicator | Boolean | True | 
| program\$1segmentation\$1flag | Boolean | True | 
| delivery\$1not\$1restricted\$1flag | Boolean | True | 

MediaTailor always sets the `segmentation_duration_flag` to `True`. MediaTailor populates the `segmentation_duration` field with the duration, in ticks, of the state content.

**Note**  
When MediaTailor sends the `time_signal` messages, it sets the `splice_command_type` field in the `splice_info_section` message to 6 (0x06).

In HLS output, for an `AdBreak` with a `time_signal` message, the output `EXT-X-DATERANGE` tag includes a `SCTE-35` field that is set to the serialized version of the `splice_info_section` message. For example, the following `EXT-X-DATERANGE` tag shows the serialized version of the `splice_info_section` message:

```
#EXT-X-DATERANGE:ID=\"1\",START-DATE=\"2020-09-25T02:13:20Z\",DURATION=300.0,SCTE35-OUT=0xFC002C00000000000000FFF00506800000000000160214435545490000000100E000019BFCC00E0030000000000000
```

In DASH output, for an `AdBreak` with a `time_signal` message, the output `EventStream` element includes a `scte35:SpliceInfoSection` element with `scte35:TimeSignal` and `scte35:SegmentationDescriptor` elements as its children. The `scte35:TimeSignal` element has a child `scte35:SpliceTime` element, and the `scte35:SegmentationDescriptor` element has a child `scte35:SegmentationUpid` element. For example, the following DASH output shows the `EventStream` element's child element structure:

```
<EventStream schemeIdUri="urn:scte:scte35:2013:xml" timescale="90000">
    <Event duration="27000000">
        <scte35:SpliceInfoSection protocolVersion="0" ptsAdjustment="0" tier="4095">
            <scte35:TimeSignal>
                <scte35:SpliceTime ptsTime="0" />
            </scte35:TimeSignal>
            <scte35:SegmentationDescriptor segmentNum="0" segmentationDuration="27000000" segmentationEventCancelIndicator="false" segmentationEventId="1" segmentationTypeId="48" segmentsExpected="0">
                <scte35:SegmentationUpid segmentationUpidFormat="hexBinary" segmentationUpidType="14">012345</scte35:SegmentationUpid>
            </scte35:SegmentationDescriptor>
        </scte35:SpliceInfoSection>
    </Event>
</EventStream>
```

You learned about using SCTE-35 messages to set up ad breaks in channel assembly, the structure and required fields for those messages, and sample HLS and DASH output that includes the SCTE-35 messages.

# Time-shifting a channel's playback
<a name="channel-assembly-time-shift"></a>

With MediaTailor channel assembly, you can time-shift a channel's playback. Time-shifting allows viewers to watch a channel's content at a time other than the original broadcast time. For example, a viewer can start watching a program from the beginning, even if they join the broadcast after it has started. Or, a viewer can pause a program and resume watching it later.

To time-shift a channel's playback, you add a `start` parameter to the channel's playback URL. The `start` parameter specifies the time when playback should begin, relative to the current time. For example, if the current time is 2:00 PM, and you want to start playback from 1:00 PM, you would set the `start` parameter to `-3600`, which is -1 hour in seconds.

The `start` parameter accepts both positive and negative values, in seconds:
+ Negative values indicate a time in the past, relative to the current time. For example, `start=-3600` means "start playback from 1 hour ago."
+ Positive values indicate a time in the future, relative to the current time. For example, `start=3600` means "start playback from 1 hour in the future."

The following example shows how to add the `start` parameter to a channel's playback URL:

```
https://a1b2c3d4e5f6.mediapackage.us-west-2.amazonaws.com/out/v1/examplechannel/index.m3u8?start=-3600
```

In this example, playback starts from 1 hour ago.

The `start` parameter is subject to the following limitations:
+ The maximum time-shift window is 24 hours in the past or future.
+ Time-shifting is only available for channels that use the linear playback mode.
+ Time-shifting is not available for channels that use the loop playback mode.

If you specify a `start` parameter that is outside the available time-shift window, MediaTailor returns an error.