DEV Community

Cover image for DRM Plugin for Ant Media Server: Secure Streaming with Widevine, FairPlay & PlayReady
Amar Thodupunoori
Amar Thodupunoori

Posted on • Originally published at docs.antmedia.io

DRM Plugin for Ant Media Server: Secure Streaming with Widevine, FairPlay & PlayReady

DRM Plugin for Ant Media Server

The Digital Rights Management (DRM) Plugin for Ant Media Server enables secure streaming by integrating with the CPIX (Content Protection Information Exchange) API. It ensures that only authorized users can access your content through encryption and multi-DRM support (Widevine, FairPlay, and PlayReady).

Key Features

  • Integration with CPIX API for content key management
  • Support for both DASH and HLS outputs
  • Multi-DRM support: Widevine, FairPlay, PlayReady

Installation

Prerequisites

Ensure the Ant Media Server is already installed and running on your machine or server instance.

1. Purchase and Install the DRM Plugin

Install the plugin JAR file into your Ant Media plugins directory:


bash
sudo cp DRM-Plugin-bundle.jar /usr/local/antmedia/plugins
Restart Ant Media Server:

bash
Copy code
sudo service antmedia restart
2. Install Shaka Packager
Download Shaka Packager:

bash
Copy code
wget https://github.com/shaka-project/shaka-packager/releases/download/v3.4.1/packager-linux-x64 -O shakapackager
Move it to /usr/local/bin and make it executable:

bash
Copy code
sudo cp shakapackager /usr/local/bin/
sudo chmod +x /usr/local/bin/shakapackager
Configuration
DRM plugin configurations are managed under customSettings in your Ant Media Server application settings.

1. Navigate to Custom Settings
Open the Ant Media Server web panel

Select your application (e.g., live)

Go to Settings → Advanced

Locate customSettings

2. Add DRM Settings
Minimal Configuration
json
Copy code
{
  "customSettings": {
    "plugin.drm-plugin": {
      "enabledDRMSystems": ["Widevine"],
      "keyManagementServerURL": "{KMS_URL}"
    }
  }
}
Enable Multiple DRM Systems
json
Copy code
{
  "enabledDRMSystems": [
    "Widevine",
    "PlayReady",
    "FairPlay"
  ]
}
Available Configuration Fields
Field   Description
keyManagementServerURL  URL for CPIX key retrieval from DRM provider
enabledDRMSystems   List of DRM systems such as Widevine, FairPlay, PlayReady
encryptionScheme    "cbcs" (default) or "cenc"
hlsPlayListType LIVE (default), VOD, or EVENT
segmentDurationSecs Segment duration in seconds (default: 2)
timeShiftBufferDepthSecs    Live buffer depth (default: 60)
segmentsOutsideLiveWindow   Extra segments outside buffer (default: 5)

Multi-DRM Integration (Widevine via DoveRunner)
1. Obtain KMS Token from DoveRunner
In the DoveRunner dashboard, go to DRM Settings and copy your KMS token.

Construct the Key Management Server URL:

bash
Copy code
https://kms.pallycon.com/v2/cpix/pallycon/getKey/{YOUR_KMS_TOKEN}
Update your customSettings to include this URL.

2. Add HTML5 Player (Video.js Example)
Clone the DRM-enabled HTML5 player samples:

bash
Copy code
git clone https://github.com/doverunner/html5-player-drm-samples
sudo cp -r html5-player-drm-samples /usr/local/antmedia/webapps/live/
Copy required .html, .js, and .css files into your application web folder.

3. Publish a WebRTC Stream
Publish a WebRTC stream using Ant Media’s built-in WebRTC publish page.

Your output directory should contain:

master.mpd

master.m3u8

Playback URLs
DASH:

ruby
Copy code
https://{YOUR_ANTMEDIA_SERVER}:5443/live/streams/drm/stream007/master.mpd
HLS:

ruby
Copy code
https://{YOUR_ANTMEDIA_SERVER}:5443/live/streams/drm/stream007/master.m3u8
Generate a Widevine token using DoveRunner’s Token Generator.

Update your player's JS config with the token and stream URLs.

Open the player page — your DRM-protected stream should play successfully.

To verify DRM protection, try taking a screenshot. The player should block screen capture.

🎉 Congratulations
You have successfully:

Installed and configured the DRM Plugin

Integrated Widevine DRM using DoveRunner

Published a DRM-protected live stream

Tested playback using a DRM-enabled HTML5 player
Enter fullscreen mode Exit fullscreen mode

Top comments (0)