

# Creating an Archive output group
<a name="opg-archive"></a>

When you create a AWS Elemental MediaLive channel, you might want to include an Archive output group. For information about the use cases for an Archive output group, see [Containers, protocols, and downstream systems](outputs-supported-containers-downstream-systems.md).

**Topics**
+ [Organize encodes in an Archive output group](design-archive-package.md)
+ [Coordinate with the downstream system](archive-op-origin-server-s3.md)
+ [Create an Archive output group](creating-archive-output-group.md)

# Organize encodes in an Archive output group
<a name="design-archive-package"></a>

An Archive output group can contain the following:
+ One or more outputs.

The output contains the following:
+ One video encode. 
+ Zero or more audio encodes.
+ Zero or more captions encodes. The captions are either embedded or object-style captions.

Typically, the Archive output group mirrors the output structure of another output group. For example, it might mirror the ABR stack in an HLS output group.

This diagram illustrates an Archive output group that contains one output that holds one video encode with embedded captions, and two audio encodes. 

![\[Output group diagram showing one output with a video encode and two audio encodes.\]](http://docs.aws.amazon.com/medialive/latest/ug/images/output3-nonABR-Ve-2A.png)


This diagram illustrates an Archive output group that contains one output that holds one video encode, two audio encodes, and two object-style captions encode.

![\[Output group containing V, A, A, C, C elements representing video, audio, and caption encodes.\]](http://docs.aws.amazon.com/medialive/latest/ug/images/output4-nonABR-V-2A-2C.png)


# Coordinate with the downstream system
<a name="archive-op-origin-server-s3"></a>

The destination for an Archive output group is always in an Amazon S3 bucket. You and the Amazon S3 operator must agree about the bucket to use.

**To arrange setup of the destination**

1. Decide if you need two destinations for the output: 
   + You need two destinations in a [standard channel](plan-redundancy.md).
   + You need one destination in a single-pipeline channel.

1. We recommend that you design the full path of the destination — the Amazon S3 bucket and all the folders. See [Fields for the output destination](archive-destinations.md).

1.  Ask the Amazon S3 user to create any buckets that don't already exist. 

   With MediaLive, the Amazon S3 bucket name must not use dot notation, which means it mustn't use . (dot) between the words in the bucket name. 

1. Discuss bucket ownership with the Amazon S3 user. If the bucket belongs to another AWS account, you typically want that account to become the owner of the output. For more information, see [Controlling access to the output](#setting-dss-archive-canned-acl), after this procedure.

Note that you don't need user credentials to send to an S3 bucket. MediaLive has permission to write to the bucket 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).

## Controlling access to the output
<a name="setting-dss-archive-canned-acl"></a>

You might be sending output files to an Amazon S3 bucket that is owned by another AWS account. In this situation, you typically want the other account to become the owner of the output files (the object being put in the bucket). If the bucket owner doesn't become the object owner, you (MediaLive) will be the only agent that can delete the files when the files are no longer required.

It is therefore in everyone's interest to transfer ownership of the output files after they are in the Amazon S3 bucket.

To transfer object ownership, the following setup is required:
+ The bucket owner must add a bucket permissions policy that grants you permission to add an Amazon S3 canned access control list (ACL) when MediaLive delivers the output files to the bucket. The bucket owner should read the information in [Managing access with ACLs](https://docs.aws.amazon.com/AmazonS3/latest/userguide/acls) in the Amazon Simple Storage Service user guide. The bucket owner must set up ACL permissions for the bucket, not for the objects. 
+ The bucket owner should also set up object ownership. This feature effectively makes it mandatory (rather than optional) for the sender (MediaLive) to include the *Bucket owner full control* ACL. The bucket owner should read the information in [Controlling object ownership](https://docs.aws.amazon.com/AmazonS3/latest/userguide/about-object-ownership) in the Amazon Simple Storage Service user guide.

  If the bucket owner implements this feature, then you must set up MediaLive to include the ACL. If you don't, delivery to the Amazon S3 bucket will fail.
+ You must set up MediaLive to include the *Bucket owner full control** *ACL when it delivers to the bucket. You will perform this setup when you [create the channel](archive-destinations.md).

The S3 canned ACL feature supports ACLs other than *Bucket owner full control*. But those other ACLs are typically not applicable to the use case of delivering video from MediaLive.

# Create an Archive output group
<a name="creating-archive-output-group"></a>

You create the output group and its outputs when you [create or edit a MediaLive channel](creating-a-channel-step4.md). 

1. On the **Create channel** page, under **Output groups**, choose **Add**. 

1. In the **Add output group** section, choose **Archive**, and then choose **Confirm**. More sections appear:
   + **Archive group destination** – This section contains fields for the [output destination](archive-destinations.md). 
   + **Archive settings** – This section contains fields for the [output destination](archive-destinations.md). 
   + **Archive outputs** – This section shows the output that is added by default. An Archive output can contain only one output, so don't click **Add output**

1. In **Archive outputs**, choose the **Settings** link to view the sections for the individual output:
   + **Output settings** – This section contains fields for the [output destination](archive-destinations.md) and the [output container](archive-container.md).
   + **Stream settings** – This section contains fields for the [output streams](archive-streams.md) (the video, audio, and captions).

1. (Optional) Enter names for the output group and the output:
   + In **Archive settings**, for **Name**, enter a name for the output group. This name is internal to MediaLive; it doesn't appear in the output. For example, **Sports Game 10122017 ABR** or **tvchannel59**.
   + In **Archive outputs**, for **Name**, enter a name for the output. This name is internal to MediaLive; it doesn't appear in the output.

1. To complete the other fields, see the topics listed after this procedure.

**Topics**
+ [Fields for the output destination](archive-destinations.md)
+ [Fields for the output container](archive-container.md)
+ [Fields for the video, audio, and captions streams (encodes)](archive-streams.md)

# Fields for the output destination
<a name="archive-destinations"></a>

The following fields configure the location and names of the Archive output files (the destination).
+ **Output group** – **Archive group destination** section
+ **Output group** – **Archive settings** – **CDN settings**
+ **Output group** – **Additional settings** – **Rollover interval**
+ **Archive outputs** – **Name modifier**
+ **Archive outputs** – **Extension**

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. 

# Design the path for the output destination
<a name="archive-about-destination-path"></a>

1. Design the destination path or paths, following this syntax:

   `protocol bucket folders baseFilename nameModifier counter extension`

   For example, for a standard channel:

   `s3ssl://amzn-s3-demo-bucket/channel59/delivery/curling-20171012T033162.000000.m2ts`

   `s3ssl://amzn-s3-demo-bucket1/channel59/delivery/curling-20171012T033162.000000.m2ts`

If you have two destinations, the destination paths must be different from each other in some way. 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.

The following table maps each portion in the example to the portion in the syntax.


| Portion of the URL | Example | Comment | 
| --- | --- | --- | 
| protocol | s3ssl:// | The protocol is always s3ssl:// because the destination for an Archive output is always an S3 bucket. | 
| bucket portion of the path | amzn-s3-demo-bucket |  With MediaLive, the Amazon S3 bucket name must not use dot notation. For example, **mycompany-videos** is acceptable but **mycompany.videos** isn't.   | 
| folders portion of the path | channel59/delivery/ | The folders can be present or not, and can be as long as you want.The folders must always end with a slash. | 
| baseFilename | curling | Don't terminate the file name with a slash. | 
| nameModifier | -20171012T033162 | The modifier is optional for an Archive output. | 
| delimiter before the counter | . | MediaLive automatically inserts this delimiter. | 
| counter | 000000 | MediaLive automatically generates this counter. Initially, this is a six-digit number starting at 000000, and increasing by 1. So 000000, 000001, 000002 and so on. After 999999, the next number is 1000000 (seven digits), then 1000001, 1000002, and so on. Then from 9999999 to 10000000 (eight digits), and so on. | 
| dot before the extension | . | MediaLive automatically inserts this dot. | 
| extension | m2ts | Always m2ts. | 

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

1. Enter the different portions of the destination in the appropriate fields.     
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/medialive/latest/ug/archive-specify-destination.html)

1. Leave the **Credentials** section blank in both the **Archive group destinations** sections. MediaLive has permission to write to the S3 bucket 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. Complete the **CDN settings** field only if MediaLive must set a canned ACL whenever it sends this output to the Amazon S3 bucket.

   Use of a canned ACL typically only applies if your organization is not the owner of the Amazon S3 bucket. You should have discussed the use of a canned ACL with the bucket owner when you discussed the [destination for the output](archive-op-origin-server-s3.md#setting-dss-archive-canned-acl).

1. Complete the **Rollover interval** field in the **Archive settings** section.

   For example, **300** divides the output into separate files, each with a 300 second (5 minutes) long duration. 

   Each time the rollover expires, MediaLive closes the current file on Amazon S3 and starts a new file using the `baseFilename`, the `nameModifier`, and a sequential counter. 

   The current file is visible on Amazon S3 only after it has closed.

For more information, see the [examples](archive-examples.md). 

# Examples of destination fields for an Archive output group
<a name="archive-examples"></a>

These examples show how to set up the fields that relate to file locations. They don't show how to set up other fields such as fields in the individual outputs.

## Example 1
<a name="archive-example-1"></a>

You want to create an archive of the streaming output from TV channel 59. You want to store the output in the S3 bucket named **amzn-s3-demo-bucket**, and you want to break up the stream into 5-minute chunks.


| Field | Value | 
| --- | --- | 
| Rollover interval field in Archive settings section | 300 | 
| URL in Archive group destination A section | s3ssl://amzn-s3-demo-bucket/channel59/delivery/curling | 
| URL in Archive group destination B section | s3ssl://amzn-s3-demo-bucket/channel59/backup/curlingUsing *delivery* and *backup* as folder names is only an example. | 
| Name modifier in Archive outputs section | -\$1dt\$1For information about identifiers for variable data (such as `$dt$`), see [Identifiers for variable data in MediaLive](variable-data-identifiers.md). | 
| Extension in Archive outputs section | Leave blank to use the default (.m2ts). | 

Result: the output will be broken into files of 5 minutes (300 seconds) each. Each file will have a file name of **curling**, the time that the channel started and a counter (000000, 000001, and so on), and the file name extension. For example:
+ The first file will be **curling-20171012T033162-000001.m2ts**.
+ The second file will be **curling-20171012T033162-000002.m2ts**.

Each file will be stored in both **s3ssl://amzn-s3-demo-bucket/channel59/delivery** and **s3ssl://amzn-s3-demo-bucket/channel59/backup**. 

A given file is not visible in Amazon S3 while it is being written. As soon as the rollover happens (or if the user stops the channel), MediaLive closes the current file. At that point, the file becomes visible.

## Example 2
<a name="archive-example-3"></a>

You want to create an archive of highlights from the curling game that are also being streamed (in a separate HLS output group). You want to create three outputs: one that has audio languages for Europe, one for audio languages for Asia, and one for audio languages for Africa. You want to store the outputs in the S3 buckets named **amzn-s3-demo-bucket1** and **amzn-s3-demo-bucket2**. You want to break up the stream into 5 minute chunks. 


| Field | Value | 
| --- | --- | 
| Rollover interval field in Archive settings section | 300 | 
| URL in Archive group destination A section | s3ssl://amzn-s3-demo-bucket1/sports-delivery/highlights/curling/10312017In this example, the **10312017** folder is set to match today's date. | 
| URL in Archive group destination B section | s3ssl://amzn-s3-demo-bucket2/sports-delivery/highlights/curling/10312017In this example, the paths have different bucket names. | 
| Name modifier in Archive outputs section |  Choose **Add output** twice: two more **Output** lines are added to this section, for a total of three lines. In each line, enter a modifier: **-audiogroup1**, **-audiogroup2**, and **-audiogroup3**.  | 
| Extension in Archive outputs section | Leave blank to use the default (.m2ts). | 

Result: three separate categories of files are created for each output. Each file has a file name of **10312017**, plus the modifier, the sequential counter, and the file name extension. For example:
+ `10312017-audiogroup1-000000.m2ts`, `10312017-audiogroup2-000000.m2ts`, and `10312017-audiogroup3-000000.m2ts`. 
+ `10312017-audiogroup1-000001.m2ts`, `10312017-audiogroup2-000001.m2ts`, and `10312017-audiogroup3-000001.m2ts`. 

Each file will be stored in both `s3ssl://amzn-s3-demo-bucket1/sports-delivery/highlights/curling` and `s3ssl://amzn-s3-demo-bucket2/sports-delivery/highlights/curling`.

A given file is not visible in Amazon S3 while it is being written. As soon as the rollover happens (or if the user stops the channel), MediaLive closes the current file. At that point, the file becomes visible.

# Fields for the output container
<a name="archive-container"></a>

The following fields relate to the packaging and delivery of the archive transport stream:
+ In **Output settings** – **Container Settings** section
+ In **Output settings** – **PID settings** section

For all these fields, optionally change any values. For details about a field, choose the **Info** link next to the field in the MediaLive console.

# Fields for the video, audio, and captions streams (encodes)
<a name="archive-streams"></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)