

# Creating a CMAF packaging configuration


Create a packaging configuration that formats content for devices that support Apple HLS fragmented MP4 (fMP4).

**To create a CMAF packaging configuration (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 **Video on demand**, choose **Packaging groups**.

1. On the **Packaging groups** page, choose the group that will contain the configuration that you're creating.

1. On the details page for the packaging group, under **Packaging configurations**, choose **Manage configurations**.

1. On the **Manage packaging configurations** page, under **Packaging configurations**, choose **Add** and select **New config**.

1. Complete the fields as described in the following topics:
   + [General settings fields](cfigs-cmaf-new.md)
   + [Manifest settings fields](cfigs-cmaf-manset.md)
   + [Stream selection fields](cfigs-cmaf-include-streams.md)
   + [Encryption fields](cfigs-cmaf-encryption.md)

1. Choose **Save**.

If you exceed the quotas for your account when you're creating a packaging configuration, you get an error. If you get an error similar to Too many requests, please try again. Resource limit exceeded, either you have exceeded the API request quotas, or you have already reached the maximum number of packaging groups allowed on your account. If this is your first group, or if you think you mistakenly received this error, use the Service Quotas console to [request quota increases](https://console.aws.amazon.com/servicequotas/home?region=us-east-1#!/services/mediapackage/quotas). For more information about quotas in MediaPackage, see [Quotas in AWS Elemental MediaPackage](quotas.md).

# General settings fields


Provide general settings that apply to the entire packaging configuration.

1. For **ID**, enter a name that describes the configuration. The ID is the primary identifier for the configuration, and must be unique for your account in the Region.

1. For **Package type**, choose **Common Media Application Format (CMAF)**.

1. (Optional) For **Segment duration**, enter the duration (in seconds) of each segment. Enter a value equal to, or a multiple of, the input segment duration. If the value that you enter is different from the input segment duration, AWS Elemental MediaPackage rounds segments to the nearest multiple of the input segment duration.

# Manifest settings fields


Specify the format of the manifest that AWS Elemental MediaPackage delivers from an asset that uses this packaging configuration.

1. (Optional) For **Manifest name**, enter a short string that will be appended to the endpoint URL. The manifest name creates a unique path to this endpoint. If you don't enter a value, MediaPackage uses the default manifest name, *index*.

1. (Optional) In stream sets with a single video track, select **Include IFrame-only streams** to include an additional I-frame only stream along with the other tracks in the manifest. MediaPackage inserts `EXT-I-FRAMES-ONLY` tags in the manifest, and then compiles and includes an I-frames only playlist in the stream. This playlist enables player functionality like fast forward and rewind.

1. (Optional) Select **Repeat EXT-X-KEY** if you want the service to repeat the key before every segment of the manifest. By default, the key is written just once, after the header and before the segments. If you select **Repeat EXT-X-KEY**, the manifest is written as header, key, segment, key, segment, key, and so on, with every segment preceded by the key. Set this according to the needs of the player. Selecting this option might result in an increase in client requests to the DRM server.

1. (Optional) For **Program date/time interval**, enter the interval at which MediaPackage should insert the `EXT-X-PROGRAM-DATE-TIME` tags in the manifest.

   The `EXT-X-PROGRAM-DATE-TIME` tag synchronizes the stream to the wall clock, enabling functionality like viewer seek in the playback timeline and time display on the player.

1. (Optional) For **Ad markers**, choose how ad markers are included in the packaged content. 

   Choose from the following:
   + **None** – Omit all SCTE-35 ad markers from the output.
   + **Passthrough** – Copy the SCTE-35 ad markers directly from the input HLS input stream to the output.
   + **SCTE-35 Enhanced** – Generate ad markers and blackout tags based on the SCTE-35 input messages from the input stream.

1. (Optional) Select **Include encoder configuration in segments**, for MediaPackage to place your encoder's Sequence Parameter Set (SPS), Picture Parameter Set (PPS), and Video Parameter Set (VPS) metadata in every video segment instead of in the init fragment. This lets you use different SPS/PPS/VPS settings for your assets during content playback.

# Stream selection fields


Limit which incoming bitrates are available for playback and sort the streams in the output of an asset that uses this packaging configuration. 

The minimum and maximum values take into account only the video bitrates. If the video bitrate is *below the minimum* specified rate, it's *not* included in the output, regardless of the sum of the bitrates for other tracks. Likewise, if the video bitrate is *below the maximum *specified rate, it *is* included in the output, regardless of the sum of the bitrates for other tracks.

To set minimum and maximum bitrates and sort the output, select **Enable stream selection** and complete the additional fields as follows:

1. (Optional) For **Stream order**, choose from the following:
   + **Original** to sort the output streams in the same order that the incoming source uses.
   + **Ascending** to sort the output streams starting with the lowest bitrate and ending with the highest.
   + **Descending** to sort the output streams starting with the highest bitrate and ending with the lowest.

1. (Optional) For **Min video bitrate**, enter the minimum bitrate threshold (in bits per second) that video tracks must be at or above to be available for playback from this endpoint. This ensures that tracks are *at least* a certain bitrate.

1. (Optional) For **Max video bitrate**, enter the maximum bitrate threshold (in bits per second) that video tracks must be at or below to be available for playback from this endpoint. This ensures that tracks are *no more than* a certain bitrate.

# Encryption fields
New SPEKE option for CMAF

MediaPackage now supports CMAF SPEKE Version 2.0 for VOD.New CMAF encryption options

MediaPackage now offers constant IV and multiple system IDs for CMAF packaging configurations.

Protect your content from unauthorized use through content encryption and digital rights management (DRM). AWS Elemental MediaPackage uses the [AWS Secure Packager and Encoder Key Exchange (SPEKE) API](https://aws.amazon.com/media/tech/speke-basics-secure-packager-encoder-key-exchange-api/) to facilitate content encryption and decryption by a DRM provider. Using SPEKE, the DRM provider supplies encryption keys to MediaPackage through the SPEKE API. The DRM provider also supplies licenses to supported media players for decryption. For more information about how SPEKE is used with services and features running in the cloud, see [AWS cloud-based architecture](https://docs.aws.amazon.com/speke/latest/documentation/what-is-speke.html#services-architecture) in the *Secure Packager and Encoder Key Exchange API Specification guide*.

**Note**  
To encrypt content, you must have a DRM solution provider, and be set up to use encryption. For information, see [Content encryption and DRM in AWS Elemental MediaPackage](using-encryption.md). 

To serve content with copyright protection, Select **Enable encryption** and complete the additional fields as follows:

1. For **System IDs**, enter unique identifiers for your streaming protocol and DRM system. Provide up to two system IDs. If you provide more than one system ID, enter one per line. If you do not know your IDs, ask your DRM solution provider.

1. For **URL**, enter the URL of the API Gateway proxy that you set up to talk to your key server. The API Gateway proxy must reside in the same AWS Region as MediaPackage.

   The following example shows a URL. 

   ```
   https://1wm2dx1f33.execute-api.us-west-2.amazonaws.com/SpekeSample/copyProtection
   ```

1. (Optional) For **SPEKE version**, choose the SPEKE version that you'd like to use for encryption. SPEKE Version 1.0 is the legacy version that uses CPIX Version 2.0, and supports single key encryption. SPEKE Version 2.0 uses CPIX Version 2.3, and supports multiple key encryption. For more information about using SPEKE with MediaPackage, see [Content encryption and DRM in MediaPackage](https://docs.aws.amazon.com/mediapackage/latest/ug/using-encryption.html). 

   If you select **SPEKE Version 2.0**, then also choose a **Video encryption preset** and an **Audio encryption preset**. The video and audio presets determine which content keys MediaPackage uses to encrypt the audio and video tracks in your stream. For more information about these presets, see [SPEKE Version 2.0 presets](drm-content-speke-v2-presets.md).

    When using SPEKE Version 2.0, MediaPackage disables key rotation.

1. (Optional) For **Constant initialization vector** enter a 128-bit, 16-byte hex value represented by a 32-character string, to be used with the key for encrypting content.

1. For **Role ARN**, enter the Amazon Resource Name (ARN) of the IAM role that provides you access to send your requests through API Gateway. Get this from your DRM solution provider.

   The following example shows a role ARN. 

   ```
   arn:aws:iam::444455556666:role/SpekeAccess
   ```