

# Creating a MediaPackage output group
<a name="opg-mediapackage"></a>

When you create a MediaLive channel, you might want to include a MediaPackage output group. For information about the use cases for a MediaPackage output group, see [Containers, protocols, and downstream systems](outputs-supported-containers-downstream-systems.md). For information about choosing between an HLS and MediaPackage output group, see [Choosing between the HLS output group and MediaPackage output group](hls-choosing-hls-vs-emp.md).

**Topics**
+ [Organize encodes in a MediaPackage output group](design-emp-hls-package.md)
+ [Coordinate with the MediaPackage operator](origin-server-emp.md)
+ [Create a MediaPackage output group](creating-mediapackage-output-group.md)

# Organize encodes in a MediaPackage output group
<a name="design-emp-hls-package"></a>

An MediaPackage output group is typically set up as a video ABR stack. A video ABR stack is an output group that contains the following:
+ More than one outputs.

Each output can contain the following:
+ One video encode (rendition). Typically, each video encode is a different resolution. 
+ Zero or more audio encodes. 
+ Zero or more captions encodes. The captions are embedded or object-style captions.

This diagram illustrates a MediaPackage output group when the captions are embedded in the video. Each video encode is in a separate output. The captions are in each video output. Each audio encode is in a separate output.

![\[Output group diagram showing video outputs with embedded captions and separate audio outputs.\]](http://docs.aws.amazon.com/medialive/latest/ug/images/output13-ABR-2Ve-2Asep.png)


This diagram illustrates a MediaPackage output group when the captions are sidecar captions. Each encode is in its own output.

![\[Output group diagram showing six outputs: two V, two A, and two C, representing video, audio, and captions.\]](http://docs.aws.amazon.com/medialive/latest/ug/images/output14-ABR-2V-2Asep-2C.png)


# Coordinate with the MediaPackage operator
<a name="origin-server-emp"></a>

You and the operator of the AWS Elemental MediaPackage service must agree about the destination for the output of your MediaPackage output group.

**Note**  
You can send to AWS Elemental MediaPackage by creating a MediaPackage output group or by creating an HLS output group. See [Choosing between the HLS output group and MediaPackage output group](hls-choosing-hls-vs-emp.md) for a description of the differences.

## MediaPackage v1 (HLS) coordination
<a name="coordinate-emp-v1"></a>

**To arrange setup of the MediaPackage v1 destination**

1. Ask the MediaPackage user to create one channel. Even if the MediaLive channel is a [standard channel](plan-redundancy.md) (with two pipelines), you need only one MediaPackage channel.

1. Obtain the ID of the MediaPackage channel. For example, `curling-live`. The channel ID is case sensitive. 

## MediaPackage v2 (CMAF) coordination
<a name="coordinate-emp-v2"></a>

**To arrange setup of the MediaPackage v2 destination**

1. Ask the MediaPackage user to create MediaPackage v2 channels in the required regions. Obtain the following information for each destination:
   + AWS region name (for example, `us-east-1` or `eu-west-1`)
   + MediaPackage channel group name
   + MediaPackage channel name
   + Which ingest endpoint (ENDPOINT\$11 or ENDPOINT\$12) is the preferred input for the MediaPackage channel

1. If you plan to use additional destinations for redundancy or cross-region delivery, coordinate the setup of additional MediaPackage v2 channels as needed.

**Note**  
You don't need user credentials to send a MediaPackage output group to MediaPackage. MediaLive has permission to write to MediaPackage 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).

# Create a MediaPackage output group
<a name="creating-mediapackage-output-group"></a>

When you [planned the workflow for your channel](identify-downstream-system.md), you might have determined that you want to include a MediaPackage output group. (Or you might have decided to use an [HLS output group to deliver to MediaPackage](hls-destinations-emp.md).)

## Create MediaPackage output groups
<a name="emp-create-procedure"></a>

You can create MediaPackage output groups for two different MediaPackage versions:
+ **MediaPackage v1 (HLS)** - Uses HLS ingest protocol and requires a MediaPackage channel ID
+ **MediaPackage v2 (CMAF)** - Uses CMAF ingest protocol and requires MediaPackage channel group name and channel name

### MediaPackage v1 (HLS) procedure
<a name="emp-v1-procedure"></a>

1. On the **Create channel** page, in the **Output groups** section, choose **Add**. The content pane changes to show the **Add output** group section. 

1. Choose **MediaPackage**, and then choose **Confirm**. More sections appear: 
   + **MediaPackage destination**
   + **MediaPackage settings**
   + **MediaPackage outputs**–This section shows the single output that is added by default.

1. In the **MediaPackage destination** section, for **MediaPackage channel ID**, enter the channel ID for that channel. For example, `curling-live`.

1. (Optional) In the **MediaPackage settings** section, for **Name**, enter a name for the output group.

1. If you need to specify MediaPackage V2 group settings select it from the dropdown and specify settings as needed

1. If your plan includes more than one output in this output group, then in **MediaPackage outputs**, choose **Add output** to add the appropriate number of outputs.

   You might want to add an output in order to implement trick-play. For more information about this feature and for instructions on setting it up in the channel, see [Trick-play track via the Image Media Playlist specification](trick-play-roku.md).

1. Choose the first **Settings** link to view the sections for the first output. The section contains fields for the [output streams](hls-streams-section.md) (the video, audio, and captions).

1. [Save the channel](creating-a-channel-step9.md).

### MediaPackage v2 (CMAF) procedure
<a name="emp-v2-procedure"></a>

1. On the **Create channel** page, in the **Output groups** section, choose **Add**. The content pane changes to show the **Add output** group section. 

1. Choose **MediaPackage**, and then choose **Confirm**. More sections appear: 
   + **MediaPackage destination**
   + **MediaPackage settings**
   + **MediaPackage outputs**–This section shows the single output that is added by default.

1. In the **MediaPackage destination** section, configure the primary destination:

   1. For **Region**, select the region that contains your MediaPackage v2 channel. This defaults to your current region.

   1. For **MediaPackage channel group name**, select the MediaPackage channel group name that contains your MediaPackage v2 channel.

   1. For **MediaPackage channel name**, select your MediaPackage v2 channel.

   1. For **Endpoint ID**, select which MediaPackage ingest endpoint should receive content:
      + **ENDPOINT\$11** - Content is sent to the first ingest endpoint
      + **ENDPOINT\$12** - Content is sent to the second ingest endpoint

1. (Optional) To configure additional destinations for redundancy or cross-region delivery, expand the **Additional destinations** section and click **Add destination**. For each additional destination, repeat the configuration steps above, specifying the region, channel group name, channel name, and endpoint ID for each additional MediaPackage channel. Standard channels support up to two additional destinations, while single pipeline channels support one additional destination.

1. (Optional) In the **MediaPackage settings** section, for **Name**, enter a name for the output group.

1. If your plan includes more than one output in this output group, then in **MediaPackage outputs**, choose **Add output** to add the appropriate number of outputs.

1. Choose the first **Settings** link to view the sections for the first output. The section contains fields for the [output streams](hls-streams-section.md) (the video, audio, and captions). CMAF ingest outputs only allow a single stream type per output.

1. [Save the channel](creating-a-channel-step9.md).

# Streams section
<a name="mediapackage-encode-packaging"></a>

The following fields relate to the encoding of the video, audio, and captions streams (encodes) in the output. 
+ **Stream settings** section

For information about creating encodes, see the following sections:
+ [Set up the video encode](creating-a-channel-step6.md)
+ [Set up the audio encodes](creating-a-channel-step7.md)
+  [Set up the captions encodes](creating-a-channel-step8.md)

## Packaging of video encodes and audio-only encodes
<a name="mediapackage-audio-rendition-handling"></a>

MediaLive handles the packaging of encodes within each output as follows:
+ If an output contains both video and audio (and optionally captions), the audio rendition is marked as **program audio**.
+ If an output doesn't contain video, the audio rendition is marked as **audio only** and each audio encode is marked as **ALTERNATE\$1AUDIO\$1NOT\$1AUTO\$1SELECT**.

## Setting the width and height of the video
<a name="mediapackage-width-height"></a>

This section refers to the fields in **Stream settings**, **Video**.

You must specify values in **Width** and **Height**. The MediaPackage output group doesn't support leaving these fields blank to use the width and height from the source video.

## Setting the aspect ratio of the video
<a name="mediapackage-aspect-ratio"></a>

This section refers to the fields in **Stream settings**, **Video**, **Aspect ratio**.

You must set **PAR control** to **SPECIFIED**. The MediaPackage output group doesn't support setting the aspect ratio of the output to follow the source video. When you choose **SPECIFIED**, you must complete **PAR numerator** and **PAR denominator**. You can set the **AFD** fields as you want.

## Setting the frame rate of the video
<a name="mediapackage-framerate"></a>

This section refers to the fields in **Stream settings**, **Video**, **Frame rate**.

You must set **Framerate control** to **SPECIFIED**. The MediaPackage output group doesn't support setting the frame rate of the output to follow the source video. When you choose **SPECIFIED**, you must complete **Framerate numerator** and **Framerate denominator**. You can set the scan type as you want; it doesn't relate directly to the frame rate.

## Setting up for GOPs and segments
<a name="mediapackage-gop-segments"></a>

This section refers to the fields in **Stream settings**, **Video**, **GOP structure**.

For the video, you must set the GOP size to ensure that the output from MediaLive has a segment size that is close to the segment size that you specify in MediaPackage. MediaLive and MediaPackage work together to obtain a final segment size. The logic is as follows:
+ In MediaLive you specify the **GOP size** and **GOP size units** fields.
+ MediaLive calculates the GOP duration, taking into account the frame rate that you specify in the **Video** section of the **Output **page.
+ In MediaPackage you specify the segment duration. You always specify a whole number. This segment duration is the *desired *minimum duration. 
+ When MediaPackage receives the video from MediaLive, it determines how much it must adjust the segment duration to fit a whole number of GOPs into the segment. The segment duration can only be adjusted up, never down. This adjusted segment duration appears in the manifest that MediaPackage produces.

**Example 1**

Assume that in MediaLive you set the GOP size to 60 frames. You set the frame rate to 29.97. These two values result in a GOP duration of 2.002 seconds.

Assume that in MediaPackage you set the segment duration to 6 seconds. This segment duration is the *desired* minimum duration.

When MediaPackage receives the video from MediaLive, it determines how much it must adjust the segment duration to fit a whole number of GOPs into the segment. In this case, the segment duration must be adjusted to 6.006 seconds (three GOPs, where each GOP is 2.002 seconds long). 

**Example 2**

Assume that in MediaLive, you set the GOP size to 90 frames. You set the frame rate to 30. These two values result in a GOP duration of 3 seconds.

Assume that in MediaPackage you set the segment duration to 4 seconds. This segment duration is the *desired* minimum duration.

When MediaPackage receives the video from MediaLive, it determines how much it must adjust the segment duration to fit a whole number of GOPs into the segment. In this case, the segment duration must be adjusted to 6 seconds (two GOPs, where each GOP is 3 seconds long).

## Other encode fields
<a name="mediapackage-general-encode-settings"></a>

For information about the fields in each type of encode, see the following sections:
+ [Set up the video encode](creating-a-channel-step6.md)
+ [Set up the audio encodes](creating-a-channel-step7.md)
+  [Set up the captions encodes](creating-a-channel-step8.md)

# Result of this procedure
<a name="mediapackage-create-result"></a>

With a MediaPackage output group, you don't configure as many fields as you do with a regular HLS output group. Instead, MediaLive automatically sets up the output group as follows:

**Destination**
+ The output from pipeline 0 is mapped to the first ingest endpoint in the MediaPackage channel. The output from pipeline 1 (if you have set up a standard channel) is mapped to the second ingest endpoint.

  The mapping of each pipeline to an ingest endpoint never changes. The only change that can occur in the mappings is if you upgrade a single-pipeline input to a standard-class input, or upgrade a single-pipeline channel to a standard channel. In both these cases, pipeline 1 will be mapped to the second ingest endpoint (which has always existed).

  You can view details of the mappings after you have created the channel. Follow the steps in [Viewing channel details](https://docs.aws.amazon.com/mediapackage/latest/ug/channels-view) in the *AWS Elemental MediaPackage User Guide*. In the **Inputs** section, the first item (ingest endpoint) always maps to pipeline 0 in the MediaLive channel, and the second item always maps to pipeline 1.
+ The output is delivered to MediaPackage using WebDAV. The output is always a live stream, not a VOD stream.
+ The output name or names are automatically set to `Output n`, where n is an integer starting at 1. 
+ The `nameModifier` for each output is automatically set to match the output name.

**Container**
+ The codec specification is RFC 4281. The player device might use this information.
+ The program date time (PDT) period is set to 1 second.
+ The PAT interval is set to 0, which means a single PAT is inserted at the beginning of each segment.
+ The PMT interval is set to 0, which means a single PMT is inserted at the beginning of each segment.

**Resiliency**
+ Resiliency is handled as follows. If input into MediaLive is lost, then the behavior is for MediaLive to pause delivery. MediaPackage expects this behavior and handles the loss by switching to the other input.

**SCTE-35**
+ Passthrough of SCTE-35 messages is always enabled. If you don't want SCTE-35 markers in the outputs, you can remove them in the channel in AWS Elemental MediaPackage. For information about SCTE-35 handling in a MediaPackage output, see [Processing SCTE 35 messages](scte-35-message-processing.md).

**ID3**
+ ID3 metadata is enabled.
+ The ability to insert ID3 markers through the output group is disabled. However, you can set up to pass through ID3 markers that are in the input, and you can insert ID3 markers using the MediaLive schedule. For information about ID3 handling in a MediaPackage output, see [Working with ID3 metadata](id3-metadata.md).