Lab
  • DRM packaging tutorialsCourse
  • 5 things you need to know about multi-DRMCourse
  • Getting started with Doverunner Anti PiracyCourse
  • Getting started with Doverunner Forensic WatermarkingCourse
  • Getting started with Doverunner Mobile App SecurityCourse
  • Getting started with Doverunner Multi-DRMCourse
  • Getting started with Doverunner Transcoding & PackagingCourse
  • Packaging content with the DRM CLI PackagerLesson · DRM packaging tutorials
한국어

Live Multi-DRM packaging with AWS Elemental MediaLive and MediaPackage

Shows, with a real run, how AWS Elemental MediaPackage v2 encrypts a live CMAF stream with Doverunner Multi-DRM over SPEKE v2, with multi-key and key rotation.

Lesson 36 min

DRM: —Status: idle

Transcript
Live Multi-DRM packaging with AWS Elemental MediaLive and MediaPackage. Encrypt a live CMAF stream, and rotate its keys. If you stream live on AWS, you can add Doverunner Multi-DRM without changing your encoder. In this video, a video file loops through AWS Elemental MediaLive, standing in for a live feed. MediaLive sends it to AWS Elemental MediaPackage. MediaPackage encrypts the stream as it arrives. For the keys, it asks the Doverunner key server, using the SPEKE version 2 protocol. It publishes two endpoints: DASH for PlayReady and Widevine, and HLS for FairPlay. Your players get licenses from Doverunner. You need four things. An AWS account with access to IAM, MediaLive, and MediaPackage. A Doverunner Console account, for your KMS token, with the key rotation right turned on. If it's not on yet, ask Doverunner support. A content ID of your choice, which Doverunner calls the CID, and which we'll use as the Resource ID. And a source video in S3. In this video, that's Big Buck Bunny. In the Doverunner Console, open Multi-DRM, then Settings. Click Retrieve Secret Information, and your KMS token appears here. Treat it like a password. It goes only into the key server URL in MediaPackage, nowhere else. MediaPackage needs a role to call the key server. In IAM, create a role with a custom trust policy. Allow the MediaPackage service principals to assume it. For MediaPackage version 2, that includes the MediaPackage V2 principal, which the older guide doesn't mention. Attach the API Gateway invoke permission, and name the role SPEKEAccess. Now open MediaPackage, and go to Live version 2. Create a channel group, then a channel inside it. Set the input type to CMAF. MediaLive will push its output to this channel. You don't need a channel policy, because MediaLive runs in the same account. Add an origin endpoint for DASH. Choose CMAF as the container, and turn on Encrypt content. Pick the CENC method, with PlayReady and Widevine. Enter your CID as the Resource ID. Paste the key server URL for SPEKE version 2, with your KMS token. Select the SPEKEAccess role, and SPEKE version 2.0. For multi-key, set the video preset to two. SD and HD video then get separate keys. We leave audio unencrypted. To rotate keys, open Additional configuration and set a key rotation interval. MediaPackage version 2 accepts at least 300 seconds, so we use five minutes. Then add key-rotation equals true to the key server URL. The two must match, or playback can fail. The license token needs key rotation turned on as well. Each rotation means a new license for every viewer, so plan for that on large live events. Add a second endpoint for Safari. Choose CMAF again, but with the CBCS method, and add FairPlay. Use the same Resource ID, URL, and role. This time, set the video preset to one, so the video uses a single key. That keeps the Safari test simple. Add an HLS manifest, and leave the public access policy on so the players can reach both endpoints. Now the source. In MediaLive, create an input of type MP4, and give it the S3 location of your video. A real live stream would use RTMP, SRT, or another live input here instead. When you attach the input to a channel, set Source end behavior to Loop, so the video plays forever. Create a MediaLive channel. Use a single pipeline channel to keep costs low. For the IAM role, use the MediaLive access role, which the console can create for you. Then attach the input you just made. Add an audio selector, so the channel can find the audio track. Add an output group, and choose CMAF Ingest. For the destination, paste the ingest URL from your MediaPackage channel. Then add the outputs: a 720p video, a 360p video, and an audio output. In CMAF Ingest, each output carries only one track type, so audio needs its own. MediaLive doesn't encrypt anything here. MediaPackage does that. Create the channel, and click Start. After about a minute, the state changes to Running. The video is now looping as a live stream, and MediaPackage is encrypting it. Check the manifests. The DASH manifest lists content protection for Widevine and PlayReady, with the CENC scheme. The HLS manifest has a FairPlay key entry. Each key rotation adds a new one, so you will see more than one over time. The playlists point to keys, never to the keys themselves. Now play it with the DRM playback tester in the Doverunner Lab Playground. Choose Custom content, and paste the DASH manifest URL for Chrome or Edge, or the HLS manifest URL for Safari. Then open License policy and token tools. Build a token for your CID with key rotation turned on, and a policy for the SD and HD tracks. Paste the token into the tester, load the stream, and press play. The Token tab shows key rotation turned on, and the Timeline shows a new license request after each rotation. To recap. Create a role for the key server. Create a MediaPackage channel and two encrypted endpoints, with multi-key for DASH, a single key for FairPlay, and key rotation. Send a MediaLive stream to the channel. Verify the manifests, and play with a Doverunner license. Remember to stop the MediaLive channel when you're done, because it bills while it runs. Details are in the Doverunner Docs guide. Learn more about Doverunner Multi-DRM at Doverunner Docs.

What you will build

If you stream live on AWS, you can add Doverunner Multi-DRM without changing your encoder. In this lesson, a video file loops through AWS Elemental MediaLive, standing in for a live feed. MediaLive sends it to AWS Elemental MediaPackage (v2), which encrypts the stream as it arrives. For the keys, MediaPackage asks the Doverunner key server using the SPEKE v2 protocol. It publishes two endpoints: DASH for PlayReady and Widevine, and HLS for FairPlay. Your players get licenses from Doverunner.

You can watch the stream this run produced in the Multi-DRM live stream demo.

Before you start

  • AWS account with access to IAM, MediaLive, and MediaPackage
  • Doverunner Console account (console.doverunner.com) for your KMS token, with the key rotation right turned on. If it is not on yet, ask Doverunner support
  • A content ID (CID) of your choice. You enter it as the Resource ID in MediaPackage and use the same CID in your license tokens
  • A source video in S3 (this lesson uses Big Buck Bunny)

1. Get the KMS token

In Doverunner Console, go to Multi DRM > Settings and select Retrieve Secret Information. Your KMS token appears in the KMS Token row. Treat it like a password: it goes only into the key server URL in MediaPackage.

MediaPackage v2 uses the SPEKE v2 key server URL, for both CENC and CBCS endpoints:

https://drm-kms.doverunner.com/v2/cpix/getKey?enc-token=<KMS token>

2. Create the IAM role

MediaPackage needs a role to call the key server. In IAM, create a role with a custom trust policy that lets the MediaPackage service principals assume it. For MediaPackage v2, include both mediapackage.amazonaws.com and mediapackagev2.amazonaws.com; without the v2 principal, endpoint creation fails with "unable to assume the IAM role". Attach AmazonAPIGatewayInvokeFullAccess and name the role SPEKEAccess.

3. Create the MediaPackage channel

Open MediaPackage and go to Live v2. Create a channel group, then a channel inside it, with the input type CMAF. MediaLive pushes its output to this channel. You don't need a channel policy when MediaLive runs in the same account.

4. DASH endpoint (PlayReady + Widevine, multi-key)

Add an origin endpoint with CMAF as the container and turn on Encrypt content:

  • Encryption method: CENC, with PlayReady and Widevine
  • Resource ID: your CID
  • Key server URL: the SPEKE v2 URL from step 1
  • Role ARN: SPEKEAccess
  • SPEKE version: 2.0
  • Video preset: 2 (multi-key: SD and HD video get separate keys)
  • Audio: unencrypted in this lesson

Add a DASH manifest.

5. Key rotation

Under Additional configuration, set the Key rotation interval. MediaPackage v2 accepts 300 seconds or more, so this lesson uses 300. Then add &key-rotation=true to the key server URL. The two must match, or playback can fail. The license token also needs key rotation turned on. Each rotation means a new license for every viewer, so plan for that on large live events.

6. HLS endpoint (FairPlay)

Add a second endpoint for Safari: CMAF again, with the CBCS method and FairPlay added. Use the same Resource ID, key server URL, and role. Set the video preset to 1 so the video uses a single key, which keeps the Safari test simple. Add an HLS manifest, and leave the public access policy on so players can reach both endpoints.

7. MediaLive input

In MediaLive, create an input of type MP4 with the S3 location of your video. A real live stream uses RTMP, SRT, or another live input instead. When you attach the input to the channel, set Source end behavior to Loop.

8. MediaLive channel and output

  1. Create a single-pipeline channel to keep costs low. For the IAM role, use MediaLiveAccessRole, which the console can create for you. The channel can't start until a role is set.
  2. Attach the input and add an audio selector.
  3. Add an output group of type CMAF Ingest (not "MediaPackage", which is for v1) and paste the ingest URL of your MediaPackage channel as the destination.
  4. Add the outputs: 720p video, 360p video, and audio. In CMAF Ingest each output carries one track type only, so audio needs its own output.

MediaLive does not encrypt anything here. MediaPackage does.

9. Start the channel

Create the channel and select Start. After about a minute the state changes to Running: the video now loops as a live stream and MediaPackage encrypts it.

10. Verify the output

  • DASH: ContentProtection for Widevine and PlayReady with the cenc scheme, and one KID per video track
  • HLS: a FairPlay key entry (skd://). Each rotation adds a new one, so you see more over time

The playlists point to keys, never contain the keys themselves.

11. Play it with a Doverunner license

Open the DRM playback tester in Doverunner Lab and choose Custom content. Paste the DASH manifest URL for Chrome or Edge, or the HLS manifest URL for Safari. In License policy & token tools, build a token for your CID with key rotation turned on and a policy for the SD and HD tracks. Paste the token, load the stream, and press play. The Token & keys tab shows key rotation on, and the Timeline shows a new license request after each rotation.

Stop the MediaLive channel when you're done: it bills while it runs.

Next steps

  • For every field and option, see the AWS Elemental MediaPackage guide in Doverunner Docs.
  • For file-based (VOD) packaging on AWS, see the MediaConvert lesson in this course.