

# 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.