Skip to navigation

Set up DRM encryption

Implement DRM protection with Widevine, PlayReady, and FairPlay for secure video streaming.

Digital Rights Management (DRM) is an essential security feature for video content streamed via FastPix. By integrating DRM, you can prevent unauthorized content usage through methods like:

  • Screen recording
  • Screen sharing
  • Downloading tools

With DRM, video segments are encrypted using MPEG Common Encryption in CBCS mode, employing AES symmetric encryption. Additionally, a license request is required to deliver a decryption key, enabling video playback.

FastPix supports the industry-standard DRM protocols for secure video delivery:

  • Google Widevine: Android devices and Chrome browsers
  • Microsoft PlayReady: Windows platforms, including Xbox
  • Apple FairPlay: Apple devices (Safari browsers on macOS, iOS, and iPadOS)

NOTE:
DRM is enabled per account. To turn it on, contact FastPix at support@fastpix.com and we’ll guide you through setting up Widevine, PlayReady, and FairPlay, including obtaining a FairPlay certificate if you need one. See Configure DRM for your videos for the onboarding steps.


Configure DRM for your videos

Create a workspace for DRM testing

For the best results during our beta phase, we recommend creating a new, isolated workspace for testing DRM-protected content.

  1. Navigate to the Workspace tab in your dashboard to create a workspace.
  2. Copy your workspace key (e.g., 1049319898967698465).
  3. Send this key to FastPix support, and we’ll onboard you when slots are available.


Get your DRM configuration ID

After onboarding, we’ll send you a DRM configuration ID for your workspace. This ID can also be found in the Settings tab of your dashboard. You’ll need this ID when creating media with a DRM playback policy.

Example of a DRM configuration ID: 1fd649fe-b84e-494d-b4b3-118ad6c5e4d7


NOTE

This is an example, and you will receive a unique ID.


FairPlay DRM on Apple devices

To ensure DRM-protected content plays on Apple devices (Safari on macOS, or any browser on iOS/iPadOS), you must obtain a FairPlay certificate from Apple. Without this certificate, DRM-protected content will not be playable.

Once you’ve obtained the FairPlay certificate (.cer file), upload it to the DRM section under the Settings tab of your FastPix dashboard.

If you need help obtaining a FairPlay certificate, contact FastPix support for assistance.



Creating media with a DRM playback policy

Currently, DRM can only be applied to Video on Demand (VOD) content.

To create DRM-protected media, follow these steps:

  1. Obtain your DRM configuration ID: Make sure you have the DRM configuration ID from the previous step.
  2. Create media with DRM protection: Use the DRM configuration ID and set the accessPolicy to drm in your media creation request. Below is an example of the required JSON format for creating a DRM-protected media:
{
"inputs": [
{
"type": "video",
"url": "https://static.fastpix.com/sample.mp4"
}
],
"metadata": {
"key1": "value1"
},
"accessPolicy": "drm",
"maxResolution": "1080p",
"drmConfigurationId": "1fd539fe-b84e-494d-b4b3-118ad6c5e4a4"
}

Note: To control which device security levels can play the content, or to allow offline downloads, add the security_level and download claims to the DRM token, not to this media creation request. See Control which devices can play with security_level and Offline downloads for DRM content.


Integrating DRM with a third-party player

If you’re not using the FastPix player, you can still integrate DRM-protected playback into third-party players that support industry-standard DRM systems like Widevine and FairPlay.

FastPix streams are fully compatible with any player that can handle HLS with CBCS encryption, and most players that implement Encrypted Media Extensions (EME) and Media Source Extensions (MSE) will work out of the box.


DRM License URL Formats

When integrating, you’ll need to use FastPix’s license and certificate endpoints, inserting the playbackId of your asset and a drmToken generated for the current session or user.

Widevine

https://api.fastpix.com/v1/on-demand/drm/license/widevine/{playbackId}?token={drmToken}

FairPlay

Before using FairPlay, confirm that FairPlay support is enabled on your FastPix account.

  • License URL:
    https://api.fastpix.com/v1/on-demand/drm/license/fairplay/{playbackId}?token={drmToken}
  • Certificate URL:
    https://api.fastpix.com/v1/on-demand/drm/cert/fairplay/{playbackId}?token={drmToken}


Integration examples

Below are working configurations for popular third-party players.


HLS.js (For Web)

if (Hls.isSupported()) {
const hls = new Hls({
emeEnabled: true,
drmSystems: {
'com.widevine.alpha': {
licenseUrl: 'https://api.fastpix.com/v1/on-demand/drm/license/widevine/{playbackId}?token={drmToken}'
},
'com.microsoft.playready': {
licenseUrl: 'https://api.fastpix.com/v1/on-demand/drm/license/playready/{playbackId}?token={drmToken}'
},
'com.apple.fps': {
licenseUrl: 'https://api.fastpix.com/v1/on-demand/drm/license/fairplay/{playbackId}?token={drmToken}',
serverCertificateUrl: 'https://api.fastpix.com/v1/on-demand/drm/cert/fairplay/{playbackId}?token={drmToken}',
}
}
});
hls.attachMedia(videoElement);
hls.loadSource(`https://cdn.fastpix.io/${playbackId}.m3u8?token=${playbackToken}`);
}

Video.js (with videojs-contrib-eme) - For Web

const PLAYBACK_ID = 'PLAYBACK_ID'; // Replace with actual playback ID
const DRM_LICENSE_TOKEN = 'DRM_TOKEN'; // Replace with actual DRM license token
const player = videojs('vid1'); // Initialize Video.js player
player.eme(); // Enable EME (Encrypted Media Extensions) support for DRM playback
player.src({
src: `https://stream.fastpix.com/${PLAYBACK_ID}.m3u8?token=${DRM_LICENSE_TOKEN}`, // HLS stream URL with DRM token appended as query parameter
type: 'application/x-mpegURL',
keySystems: {
'com.widevine.alpha': `https://api.fastpix.com/v1/on-demand/drm/license/widevine/${PLAYBACK_ID}?token=${DRM_LICENSE_TOKEN}`, // Widevine for Chrome, Android, and other compatible browsers
'com.apple.fps.1_0': {
certificateUri: `https://api.fastpix.com/v1/on-demand/drm/cert/fairplay/${PLAYBACK_ID}?token=${DRM_LICENSE_TOKEN}`, // FairPlay application certificate required by Safari to initiate DRM session
licenseUri: `https://api.fastpix.com/v1/on-demand/drm/license/fairplay/${PLAYBACK_ID}?token=${DRM_LICENSE_TOKEN}`, // FairPlay license server to validate playback authorization
}
}
});

Shaka Player (For Web)

const PLAYBACK_ID = 'PLAYBACK_ID'; // Replace with actual playback ID
const DRM_LICENSE_TOKEN = 'DRM_TOKEN'; // Replace with actual DRM license token
const manifestUri = `https://stream.fastpix.com/${PLAYBACK_ID}.m3u8?token=${DRM_LICENSE_TOKEN}`;
async function initApp() {
// Install polyfills
shaka.polyfill.installAll();
if (shaka.Player.isBrowserSupported()) {
initPlayer();
} else {
console.error('Shaka Player is not supported!');
}
}
async function initPlayer() {
const video = document.getElementById('video');
const player = new shaka.Player(video);
// DRM configuration
player.configure({
drm: {
servers: {
'com.widevine.alpha': `https://api.fastpix.com/v1/on-demand/drm/license/widevine/${PLAYBACK_ID}?token=${DRM_LICENSE_TOKEN}`,
'com.apple.fps.1_0': `https://api.fastpix.com/v1/on-demand/drm/license/fairplay/${PLAYBACK_ID}?token=${DRM_LICENSE_TOKEN}`
},
advanced: {
'com.apple.fps.1_0': {
serverCertificateUri: `https://api.fastpix.com/v1/on-demand/drm/cert/fairplay/${PLAYBACK_ID}?token=${DRM_LICENSE_TOKEN}`
}
}
}
});
try {
await player.load(manifestUri);
console.log('The video has now been loaded!');
} catch (e) {
console.error('Error loading video', e);
}
}
initApp();

iOS Native (AVPlayer with FairPlay)

To use FairPlay on iOS, configure AVURLAsset and implement AVAssetResourceLoaderDelegate to handle SPC (Server Playback Context) and CKC (Content Key Context) exchange. Use the following endpoints:

  • Certificate URL:

    https://api.fastpix.com/v1/on-demand/drm/cert/fairplay/{playbackId}?token={drmToken}
  • License URL:

    https://api.fastpix.com/v1/on-demand/drm/license/fairplay/{playbackId}?token={drmToken}

Refer to Apple’s FairPlay documentation for detailed implementation.


VersaPlayer (For iOS)

import VersaPlayer
// Video player controller that integrates FairPlay DRM using VersaPlayer
class VideoPlayerViewController: UIViewController,VersaPlayerDecryptionDelegate {
// Function to initialize and configure the DRM-enabled player
func initiatePlayer(videourl:String) {
let item = VersaPlayerItem(url: url)
item.isEncrypted = true
controls.handler.decryptionDelegate = self
}
//Provide the FairPlay Application Certificate
// This certificate is used to generate the SPC (Server Playback Context) request
func urlFor(player: VersaPlayer) -> URL {
return URL(string: "https://api.fastpix.com/v1/on-demand/drm/cert/fairplay/{PLAYBACK_ID}?token={DRM_LICENSE_TOKEN}")!
}
// Provide the unique Content Identifier for the video
// This ID ties the playback request to the specific asset on the license server
func contentIdFor(player: VersaPlayer) -> String {
let assetId: String = "CONTENT_ID"
return assetId
}
// Provide the License Server URL (CKC URL)
// The SPC generated with the certificate and content ID is sent here,
// and the server responds with the CKC (Content Key Context)
// which contains the decryption keys to unlock the video
func contentKeyContextURLFor(player: VersaPlayer) -> URL {
return URL(string: “https://api.fastpix.com/v1/on-demand/drm/license/fairplay/{PLAYBACK_ID}?token={DRM_LICENSE_TOKEN}")!
}
}

ExoPlayer (For Android)

playerView = findViewById(R.id.player_view); // Find the PlayerView from the layout
player = ExoPlayer.Builder(this).build() // Create a new ExoPlayer instance
playerView.player = player; // Attach the player to the PlayerView so the UI can display it
// Build the MediaItem with HLS stream and Widevine DRM configuration
val mediaItem = MediaItem.Builder()
// Set the media URI (HLS streaming URL with JWT token)
.setUri(" https://stream.fastpix.com/{PLAYBACK_ID}.m3u8?token={JWT} ")
// Configure DRM (Digital Rights Management) - Widevine in this case
.setDrmConfiguration(
MediaItem.DrmConfiguration.Builder(C.WIDEVINE_UUID)
// Set the license server URI with token
.setLicenseUri(" https://api.fastpix.com/v1/on-demand/drm/license/widevine/{PLAYBACK_ID}?token={DRM_LICENSE_TOKEN}")
.build()
)
.setMediaMetadata(MediaMetadata.Builder().setTitle("”).build()) //Set media metadata like the video title
.build()
player.setMediaItem(mediaItem). // Build the final MediaItem
player.prepare() // Prepare the player (loads manifest and initializes playback)
player.playWhenReady = true // Start playback as soon as the player is ready

Supported & tested players

FastPix DRM is tested and confirmed to work with:

  • HLS.js
  • Video.js (with videojs-contrib-eme)
  • Shaka Player
  • iOS AVPlayer (FairPlay)
  • VersaPlayer
  • ExoPlayer (Android)

If your player supports Widevine, PlayReady, or FairPlay with CBCS encryption, there’s a strong chance it will work with FastPix DRM as well. We’re always expanding our test coverage - let us know if you’ve successfully integrated with another player so we can add it to our compatibility list.



Playback DRM Content with FastPix Player

If you’re using FastPix Player, the integration process is even simpler. FastPix Player handles license requests, decryption, and browser compatibility for you - with minimal setup.

How it works:

FastPix Player supports both Widevine and FairPlay natively. During playback, it:

  1. Automatically detects whether the video is encrypted.
  2. Sends a license request using the provided DRM token.
  3. Decrypts the video securely and plays it in the user’s browser.

Required tokens:

To play DRM-protected videos, you’ll need two secure JSON Web Tokens (JWTs):

  • token: Grants permission to stream the video.
  • drm-token: Authorizes access to the DRM license server.

You can generate both tokens using the JWT Token Generator.
If you enable the “DRM License” feature during generation, you can use the same token for both fields.


Embed example

Here’s a minimal HTML snippet using FastPix Player for DRM-protected playback:

<fastpix-player
playback-id="YOUR-PLAYBACK-ID"
token="YOUR-DRM-TOKEN"
drm-token="YOUR-DRM-TOKEN">
</fastpix-player>

Replace the placeholders with:

  • YOUR-PLAYBACK-ID: The unique ID of your video asset
  • YOUR-DRM-TOKEN: The token authorizing both playback and license access

Both token and drm-token are required. If either is missing or invalid, the player will display a clear error message to help you debug.


Browser support

FastPix Player’s DRM integration works across:

DRM SystemBrowser Support
WidevineChrome, Firefox, Edge, Brave, and others
FairPlaySafari on macOS and iOS


Offline downloads for DRM content

Add a download claim set to true in the DRM token payload to allow app-level offline downloads. Viewers can download the protected content inside your app and play it back later, with DRM still enforced. Because this is a token claim, you control it per viewer and per session when you sign the DRM token, not when you create the media.

App-level downloads are supported on:

  • iOS: FairPlay
  • Android: Widevine
{
"kid": "26338ada-fcf4-4434-b5b0-2ba77dde5d98",
"aud": "media:16af5b33-cf4d-4717-9b90-ce429a124455",
"iss": "fastpix.io",
"exp": 1744866859,
"download": true
}

For how to sign a DRM token, see Generate JWTs for secure media.

To set up app-level downloads, or if you need any additional support, reach out to us at support@fastpix.com.


Note: This is an app-level download handled by your iOS or Android app, not a static MP4 download. DRM-protected renditions are not available as static MP4 files. See Enable MP4 support for offline viewing for how static MP4 downloads work for non-DRM media.



DRM security levels (Widevine L1, L2, L3)

DRM-protected content can play on some devices and be capped or blocked on others, depending on the device’s DRM security level. Whether playback is allowed for a given security level is part of the DRM configuration FastPix sets up for your account. Reach out to FastPix with your requirements, and we configure which security levels are allowed to play your content.

A security level describes where the sensitive work happens: decrypting the license key, decrypting the video, and handling the decoded frames. This runs either inside a hardware Trusted Execution Environment (TEE), an isolated part of the chip the operating system cannot read, or in normal software memory. The level is fixed in the device, so no app or setting can change it.


The three Widevine levels

LevelKeys and decryptionDecoded videoTypical devicesTypical resolution cap
L1Hardware TEEHardware secure video pathCertified Android phones and tablets, Android TV and Google TV, Fire TV, smart TVs, some ChromebooksHD to 4K
L2Hardware TEENormal memoryRare; a few devicesVaries, rarely targeted
L3Software (white-box cryptography)Normal memoryDesktop Chrome, Edge, and Firefox on Windows, macOS, and Linux; rooted or older Android devices480p to 1080p

In practice, almost every device is either L1 or L3. L1 covers devices built for the living room and modern mobile, where secure hardware exists, so they play up to 4K. L3 covers general-purpose computers, so desktop browsers using Widevine are usually capped at or below 1080p.

FastPix supports all three, so a viewer is served whichever one their device uses.

When you create DRM media, set maxResolution for the quality you want to allow. If you want to cap the resolution served to lower-security (L3) devices below what L1 devices receive, enforce that cap on your end.


Control which devices can play with security_level

Add a security_level claim to the DRM token payload to set which device security levels are allowed to play the content. This applies to Widevine only, and because it is a token claim, you set it per viewer and per session when you sign the DRM token.

Set security_level to 1 to allow playback on Widevine L1 devices only. If you omit security_level, playback is allowed on both Widevine L1 and L3 devices. This applies to Widevine only.

  • L1 applies to the Flutter and Android native players, where decryption runs in the device’s secure hardware.
  • L3 applies to software decryption, such as desktop browsers.
{
"kid": "26338ada-fcf4-4434-b5b0-2ba77dde5d98",
"aud": "media:16af5b33-cf4d-4717-9b90-ce429a124455",
"iss": "fastpix.io",
"exp": 1744866859,
"security_level": 1
}

For how to sign a DRM token, see Generate JWTs for secure media.


Block rooted devices for extra security

Detecting whether a device is rooted or jailbroken is a check you configure in your own app, not in FastPix. Because a rooted device can report a lower DRM security level, use this check to decide whether to allow or block playback in your app, on top of DRM.


Testing DRM protection

To verify that DRM is functioning correctly, take a screenshot of the video playback. If DRM is properly enforced, the video should either be replaced by a black screen or display a single frame from the beginning of the video (instead of the actual content).


Need help?

Whether you’re using FastPix Player or a third-party player, we’re here to help you set up DRM right.
Email support@fastpix.com for token generation tips, license configuration, or FairPlay certificate assistance.