

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