

# Fields for the output destination – sending to MediaStore
<a name="hls-destinations-ems"></a>

When you [planned the destinations for the HLS output group](origin-server-ems.md), you might have decided to send the output to MediaStore. You must design the destination path or paths for the output. You must then enter the different portions of the path into the appropriate fields on the console.

**Topics**
+ [Design the path for the output destination](hls-destinations-ems-design.md)
+ [Complete the fields on the console](hls-specify-destination-ems.md)

# Design the path for the output destination
<a name="hls-destinations-ems-design"></a>

Perform this step if you haven't yet designed the full destination path or paths. If you've already designed the paths, go to [Complete the fields on the console](hls-specify-destination-ems.md).

**To design the path**

1. Collect the data endpoint for the container or containers. You [previously obtained](origin-server-ems.md) this information from the MediaStore user. For example:

   `a23f.data.mediastore.us-west-2.amazonaws.com`

1. Design the portions of the destination paths that follow the data endpoint (for MediaStore). 

**Topics**
+ [The syntax for the paths for the outputs](#hls-syntax-ems)
+ [How MediaLive constructs the paths](#hls-how-construct-urls-ems)
+ [Designing the folders and baseFilename](#hls-path-ems)
+ [Designing the nameModifier](#hls-nameModifier-design-ems)
+ [Designing the segmentModifier](#hls-segmentModifier-design-ems)

## The syntax for the paths for the outputs
<a name="hls-syntax-ems"></a>

An HLS output always includes three categories of files: 
+ The main manifest
+ The child manifests
+ The media files

The following table describes the parts that make up the destination paths for these three categories of files.

The destination paths for these three categories of files are identical up to and including the *baseFilename*, which means that MediaLive sends all these categories of files to the same folder. The modifiers and file extensions are different for each category of file. When sending to MediaStore, you must send all the files to the same folder. The downstream systems expect all the files to be together.


| File | Syntax of the path | Example | 
| --- | --- | --- | 
| Main manifest files | protocol dataEndpoint path baseFilename extension | The path for a main manifest in the path *delivery* in the container, and with the file name *index*:mediastoressl://a23f.data.mediastore.us-west-2.amazonaws.com/delivery/index.m3u8 | 
| Child manifest files | protocol dataEndpoint path baseFilename nameModifier extension | The path for the child manifest for the high-resolution renditions of the output`mediastoressl://a23f.data.mediastore.us-west-2.amazonaws.com/delivery/index-high.m3u8` | 
| Media files (segments) | protocol dataEndpoint path baseFilename nameModifier optionalSegmentModifier counter extension | The path for the file for the 230th segment might be:mediastoressl://a23f.data.mediastore.us-west-2.amazonaws.com/delivery/index-high-00230.ts | 

## How MediaLive constructs the paths
<a name="hls-how-construct-urls-ems"></a>

These paths are constructed as follows:
+ The user of the AWS service should have provided you with the container names.
+ For MediaStore, you must determine the following: 
  + The folders
  + The baseFilename
  + The modifier
  + The segmentModifier

  See the sections that follow.
+ MediaLive inserts the underscore before the counter.
+ MediaLive generates the counter, which is always five digits starting at 00001.
+ MediaLive inserts the dot before the extension.
+ MediaLive selects the extension:
  + For manifest files – always` .m3u8`
  + For media files – .ts for files in a transport stream, or .mp4 for files in an fMP4 container 

## Designing the folders and baseFilename
<a name="hls-path-ems"></a>

Design a folder path and baseFilename that suits your purposes. 

If you have two destinations for each output, the destination paths must be different from each other in some way. Follow these guidelines:
+ At least one of the portions of one path must be different from the other. It is acceptable for all the portions to be different. 

  Therefore, if the buckets or containers are different, the folder path and file names for the two destinations can be different from each other, or they can be the same. For example:

  `mediastoressl://a23f.data.mediastore.us-west-2.amazonaws.com/delivery/index.m3u8`

  `mediastoressl://fe30.data.mediastore.us-west-2.amazonaws.com/delivery/index.m3u8`

  or

  `mediastoressl://a23f.data.mediastore.us-west-2.amazonaws.com/delivery/index.m3u8`

  `mediastoressl://fe30.data.mediastore.us-west-2.amazonaws.com/redundant/index.m3u8`
+ If the buckets or containers are the same, the folder path and file names for the two destinations must be different from each other. For example:

  `mediastoressl://a23f.data.mediastore.us-west-2.amazonaws.com/delivery/index.m3u8`

  `mediastoressl://a23f.data.mediastore.us-west-2.amazonaws.com/redundant/index.m3u8`

## Designing the nameModifier
<a name="hls-nameModifier-design-ems"></a>

Design the `nameModifier` portions of the file name. The child manifests and media files include this modifier in their file names. This `nameModifier` distinguishes each output from the other, so it must be unique in each output. Follow these guidelines:
+ For an output that contains video (and possibly other streams), you typically describe the video. For example, **-high** or **-1920x1080-5500kpbs** (to describe the resolution and the bitrate).
+ For an output that contains only audio or only captions, you typically describe the audio or captions. For example, **-aac** or **-webVTT**.
+ It’s a good idea to start the `nameModifier` with a delimiter, such as a hyphen, in order to separate the` baseFilename` from the `nameModifier`.
+ The `nameModifier` can include [data variables](variable-data-identifiers.md).

## Designing the segmentModifier
<a name="hls-segmentModifier-design-ems"></a>

Design the segmentModifiers portion of the destination path. The segmentModifier is optional, and if you include it, only the media file names include it. 

A typical use case for this modifier is to use a data variable to create a timestamp, to prevent segments overriding each other if the channel restarts. For example, assume that you include the timestamp **\$1t\$1-**. Segment 00001 might have the name `index-120028-00001`. If the output restarts a few minutes later (which causes the segment counter to restart), the new segment 00001 will have the name `index-120039-00001`. The new file won't overwrite the file for the original segment 00001. Some downstream systems might prefer this behavior.

# Complete the fields on the console
<a name="hls-specify-destination-ems"></a>

After you have designed the output names and destination paths, you can set up the HLS output group.

The following fields configure the location and names of the HLS media and manifest files (the destination).
+ **Output group – HLS group destination** section
+ **Output group – HLS settings – CDN** section
+ **Output group – Location – Directory structure **
+ **Output group – Location – Segments per subdirectory**
+ **HLS outputs – Output settings – Name modifier**
+ **HLS outputs – Output settings – Segment modifier**

**To set the destination for most downstream systems**

1. Complete the **URL** fields in the **HLS group destinations** section. Specify two destinations if the channel is set up as a standard channel, or one destination if it is set up as a single-pipeline channel.     
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/medialive/latest/ug/hls-specify-destination-ems.html)

1. Leave the **Credentials** section blank in both the **HLS group destinations** sections. MediaLive has permission to write to the MediaStore container via the trusted entity. Someone in your organization should have already set up these permissions. For more information, see [Access requirements for the trusted entity](trusted-entity-requirements.md).

1. In the **CDN** settings section, choose `Hls media store`.

1. If the MediaStore user gave you values to [configure the connection](origin-server-http.md), enter those values in the fields in the **CDN** settings section.