

# Creating live-to-VOD assets with AWS Elemental MediaPackage
<a name="ltov"></a>

A live-to-VOD (video on demand) asset is a portion of a live stream that's been extracted and saved for playback later. For example, you might save clips from a game for a highlight reel, or a clip of a broadcast show to use later in advertisements for the show.

To create a live-to-VOD asset in MediaPackage, create a harvest job resource. The harvest job is a request that you create for MediaPackage to extract a portion of a live stream and save the clip as a live-to-VOD asset in an Amazon S3 bucket. The job runs once, then MediaPackage keeps a record of it on your account for 90 days. This record is for reference purposes only. You can't delete or modify it.

**Important**  
To create live-to-VOD assets, you must allow MediaPackage to access and save to an Amazon S3 bucket. For instructions, see [Allowing AWS Elemental MediaPackage to access other AWS services](setting-up-create-trust-rel.md).

The following topics provide more information about live-to-VOD assets in MediaPackage.

**Topics**
+ [Live-to-VOD requirements](ltov-reqmts.md)
+ [How live-to-VOD works](ltov-how.md)
+ [Working with harvest jobs](harvest-jobs.md)

# Live-to-VOD requirements
<a name="ltov-reqmts"></a>

Keep in mind these requirements when you're creating live-to-VOD assets in AWS Elemental MediaPackage.

**Channel requirements**  
Create a new MediaPackage channel to harvest content from when there is a change to the stream in the upstream encoder (such as changes to the stream name, type, or codec). If you don't use a new channel and the start and end times of the harvest job span the change, the harvest could behave in unexpected ways.

**Endpoint requirements**  
The endpoint that you're harvesting the live-to-VOD asset from must meet these requirements:
+ Startover must be enabled and have a **startover window** of 14 days or less. To check or change the size of the window, see [Viewing a single endpoint](endpoints-view-one.md).
+ Your endpoint must serve either clear (unencrypted) or encrypted DASH or HLS content.
+ For DASH endpoints - Your DASH endpoint must use either the **Number with timeline** or **Time with timeline** segment template format. For information about creating DASH endpoints, see [Creating a DASH endpoint](endpoints-dash.md). 
+ MediaPackage VOD doesn't currently support the ingestion of encrypted assets. If you're using your harvested assets in an MediaPackage video on demand workflow and your endpoint is encrypted, create an unencrypted shadow endpoint on the same channel. To do this, deselect **allow origination** so that the new endpoint can't be used for playback. MediaPackage creates the URL for endpoints that don't have origination enabled, but MediaPackage responds with an error to playback requests sent to this endpoint.

**Live-to-VOD asset requirements**  
The live-to-VOD asset must meet these requirements:
+ Its start time must fall on or after the encoder's start time.
+ Its start and end times must be within the startover window on the endpoint.
+ Its duration must not exceed the maximum live-to-VOD manifest length, which is 24 hours.

# How live-to-VOD works
<a name="ltov-how"></a>

In the processing flow for live-to-VOD (video on demand) content, AWS Elemental MediaPackage extracts a clip of video from a live content stream. MediaPackage saves this clip as a live-to-VOD asset in Amazon S3. You can use the VOD content processing functionality in MediaPackage to deliver the asset to playback devices, or you can use a VOD encoding service that supports HLS or DASH inputs. 

Here's an overview of the main steps:

1. You create a channel and endpoint to ingest a live stream and package it for HLS or DASH output. The endpoint must meet the requirements outlined in [Live-to-VOD requirements](ltov-reqmts.md).

1. You create a harvest job, which defines the live-to-VOD asset that you're extracting from the live stream. The asset must also meet the requirements outlined in *Live-to-VOD Requirements*.

1. MediaPackage harvests the timeframe that you indicated in the harvest job. The asset is segment-accurate. This means that if you have a 6-second segment, and the harvest job has a start time of three seconds into the segment, the asset will start three seconds earlier, at the start of the segment.

   After MediaPackage harvests the asset, it saves the asset in the Amazon S3 bucket that you indicated in the harvest job. MediaPackage creates a directory within that bucket and names the parent manifest based on the information that you provided in the **Manifest key** on the harvest job. For example, if the manifest key is **thursdaynight/highlights/index.m3u8**, MediaPackage creates a `thursdaynight/highlights` directory in your Amazon S3 bucket and names the parent manifest `index.m3u8`.

   MediaPackage creates a CloudWatch event when the harvest job completes or fails. For information about events for harvest jobs, see [Harvest job notification events](cloudwatch-events-example.md#hj-status-events).

   MediaPackage keeps a read-only reference of the job on your account for 90 days. After 90 days, MediaPackage deletes the record of the job from your account. At this time, if your workflow requires it, you can reuse the identifier from harvest job.

1. At this point, the live-to-VOD functionality in MediaPackage is complete. The live-to-VOD asset is in your Amazon S3 bucket, and you can do with it what your workflow requires. For example, you can use the VOD functionality in MediaPackage or an encoding service to make the asset available for playback.

**Important**  
Create a new MediaPackage channel to harvest content from when there is a change to the stream in the upstream encoder (such as changes to the stream name, type, or codec). If you don't use a new channel and the start and end times of the harvest job span the change, the harvest could behave in unexpected ways.

# Working with harvest jobs
<a name="harvest-jobs"></a>

A harvest job represents a request to extract a live-to-VOD (video on demand) asset from an endpoint for a specific timeframe in the past. AWS Elemental MediaPackage uses information from the harvest job to determine the start and end times of the asset, and where to store it after the harvest job is complete.

A harvest job runs only once after it's been created. MediaPackage keeps a record of the job on your account for reference only. You can't modify or delete a record once you've created the harvest job. 

**Topics**
+ [Creating a harvest job](hj-create.md)
+ [Viewing harvest job details](hj-view.md)
+ [Editing a harvest job](hj-edit.md)
+ [Deleting a harvest job](hj-delete.md)

# Creating a harvest job
<a name="hj-create"></a>

Create a harvest job to extract a live-to-VOD asset from an encrypted or clear (unencrypted) live HLS or DASH stream.

**Important**  
To run a harvest job and save the live-to-VOD asset, MediaPackage must have permissions to access and write to the Amazon S3 bucket where the asset will be stored. To create a role that gives MediaPackage the right permissions, see [Allowing AWS Elemental MediaPackage to access other AWS services](setting-up-create-trust-rel.md).

You can use the MediaPackage console, the AWS CLI, or the MediaPackage API to create a harvest job. For information about creating a job through the AWS CLI or MediaPackage API, see the [AWS Elemental MediaPackage API Reference](https://docs.aws.amazon.com/mediapackage/latest/apireference/).

When you're creating a harvest job, don't put sensitive identifying information like customer account numbers into free-form fields, such as the **ID** field. This applies when you're using the MediaPackage console, MediaPackage API, AWS CLI, or AWS SDKs. Any data that you enter into MediaPackage might get picked up for inclusion in diagnostic logs or Amazon CloudWatch Events.

**To create a harvest job (console)**

1. Open the MediaPackage console at [https://console.aws.amazon.com/mediapackage/](https://console.aws.amazon.com/mediapackage/).

1. In the navigation pane, under **Live**, choose **Harvest jobs**. 

1. On the **Harvest jobs** page, choose **Create harvest job**.

1. On the **Create harvest job** page, complete the fields as described in the following topics:
   + [Basic details fields](#hj-create-basic)
   + [Start and end date and time fields](#hj-create-time)
   + [Destination fields](#hj-create-destination)

1. Choose **Create**.

## Basic details fields
<a name="hj-create-basic"></a>

The basic details of a harvest job define its identifier and the source for the live-to-VOD asset.

1. For **ID**, enter a name that describes the harvest job. The ID is the primary identifier for the harvest job. You can reuse the ID when the harvest job expires from your account. Supported characters are letters, numbers, underscores (\$1), and dashes (-).

1. For **Origin endpoint**, select the endpoint that serves the live stream that you're harvesting the live-to-VOD asset from.

    Note the following considerations. 
   + Your harvest job must fall within your MediaPackage endpoint's **startover window**. The startover window determines the time frame that assets can be harvested from your endpoint. For example, if your endpoint has a startover window of three days, you can harvest your asset anytime within that time frame.

      A MediaPackage endpoint can have a startover window between zero and 14 days. To adjust your endpoint's startover window, see [Viewing a single endpoint](endpoints-view-one.md). 
   + Your harvested live-to-VOD asset can have a maximum duration of 24 hours. To set the live-to-VOD asset duration, see [Start and end date and time fields](#hj-create-time) in this chapter.
   + Your endpoint must serve either clear (unencrypted) or encrypted DASH or HLS content.
   + MediaPackage VOD doesn't currently support the ingestion of encrypted assets. If you're using your harvested assets in an MediaPackage video on demand workflow and your endpoint is encrypted, create an unencrypted shadow endpoint on the same channel. To do this, deselect **allow origination** so that the new endpoint can't be used for playback. MediaPackage creates the URL for endpoints that don't have origination enabled, but MediaPackage responds with an error to playback requests sent to this endpoint. For more information, see [Creating live-to-VOD assets with AWS Elemental MediaPackage](ltov.md).

## Start and end date and time fields
<a name="hj-create-time"></a>

The start and end date and time information defines the time range for the harvest job. The maximum duration of the harvest job is 24 hours. Times are based on the program date time (PDT) from the encoder. To ensure synchronization between the encoder and the playback device, be sure to include `EXT-X-PROGRAM-DATE-TIME` tags in the endpoint that you're harvesting from. For instructions, see [Packager settings fields](endpoints-hls-packager.md).

**Note**  
The live-to-VOD asset timing is accurate up to the segment. This means that if you indicate a start or end time that falls within a segment, MediaPackage includes the entire segment in the asset. If you have a 3-second segment and that start time falls on the third second in the segment, the asset will begin two seconds earlier, at the start of the segment.

1. For **Date and time format**, choose the format that you're using to indicate the start and end times of the live-to-VOD asset.
   + **Local time** - the date and time is formatted according to the settings of your current browser session. Local time uses a 24-hour clock.
   + **Epoch seconds** - the date and time is formatted in seconds since the epoch.
   + **ISO-8601** - the date and time is formatted according to the ISO-8601 standard.

1. For **When the live-to-VOD asset begins**, enter when the live-to-VOD asset begins. The asset's begin time must be at the same time or after the live event started. The start time must also be within the startover window on the endpoint. If the endpoint has a window of 5 hours and the start time is 6 hours ago, the harvest job fails.

1. For **When the live-to-VOD asset ends**, enter when the live-to-VOD asset ends. The length of the asset can't exceed the startover window on the endpoint. If the endpoint has a window of 5 hours and your start time is 2019/07/29 07:15:00, the end time can't be after 2019/07/29 12:15:00. The end time must also be in the past.

## Destination fields
<a name="hj-create-destination"></a>

The destination information defines how MediaPackage saves the live-to-VOD asset after it has been harvested from the live stream.

1. For **IAM role ARN**, enter the ARN for the IAM role that provides MediaPackage access to read and write from your Amazon S3 bucket where the live-to-VOD asset will be stored. This is the role that you created in [Allowing AWS Elemental MediaPackage to access other AWS services](setting-up-create-trust-rel.md).

1. For **Amazon S3 bucket name**, enter the bucket where you want MediaPackage to store the live-to-VOD asset. The Amazon S3 bucket name must be in the same region MediaPackage is harvesting from.

1. For **Manifest key**, enter the path within the bucket to the live-to-VOD asset, including the file name for the parent manifest of the asset. If the directory structure doesn't already exist in the bucket, MediaPackage creates it. 
**Important**  
The manifest key must be unique. When you use the same manifest key for multiple harvest jobs, the newest playlist for the asset overwrites existing playlists. The only time you should reuse a manifest key is when you are harvesting the same content, such as if there was a problem with a previous harvest of the content.

# Viewing harvest job details
<a name="hj-view"></a>

View all harvest jobs that you created within the last 90 days. After 90 days, a harvest job expires from your account.

You can use the MediaPackage console, the AWS CLI, or the MediaPackage API to view a harvest job. For information about viewing a job through the AWS CLI or MediaPackage API, see the [AWS Elemental MediaPackage API Reference](https://docs.aws.amazon.com/mediapackage/latest/apireference/).

**To view harvest job details (console)**

1. Open the MediaPackage console at [https://console.aws.amazon.com/mediapackage/](https://console.aws.amazon.com/mediapackage/).

1. In the navigation pane, under **Live**, choose **Harvest jobs**. 

1. On the **Harvest jobs** page, choose the harvest job to view its details.

# Editing a harvest job
<a name="hj-edit"></a>

You can't edit a harvest job. To create a harvest job with different settings, see [Creating a harvest job](hj-create.md).

# Deleting a harvest job
<a name="hj-delete"></a>

You can't delete a harvest job.
+ To create a harvest job with different settings, see [Creating a harvest job](hj-create.md).
+ To delete a VOD asset that MediaPackage created with a harvest job, see [Delete an Object and a Bucket](https://docs.aws.amazon.com/AmazonS3/latest/gsg/DeletingAnObjectandBucket.html) in the *Amazon Simple Storage Service Getting Started Guide.*