Overview
This tutorial walks through integrating Bitmovin CENC Encoding with PallyCon CPIX DRM in TWO simple steps.
For a full working sample refer to the Appendix
Pre-requisites
-
CONTENT-ID
; your script can generate this id to uniquely identify each content -
KMS version
; this tutorial uses PallyCon KMS version 2 as it supports multi-key encryption -
PallyCon KMS URL
; most of the time it looks like this https://kms.pallycon.com/v2/cpix/pallycon/getKey/ -
KMS token
; to uniquely identify and protect your request to the PallyCon KMS
Screenshot from thePALLYCON
portal
Applicable Use cases
- Single Key for all renditions
- Multi-key i.e different keys for different renditions
In this tutorial we’ll run through use case #2 i.e Multi-Key
Step 1. Get DRM information from PallyCon
OVERVIEW
We’ll be discussing multi-key integration i.e 1 key for SD and 1 key for AUDIO. Implementation of the below logic can be found in the method _get_pallycon_drm_config @ cenc_drm_content_protection.py
STEPS
- Get the values from the pre-requisites section and update them respectively
...
CONTENT_ID = "my-unique_content_id"
PALLYCON_KMS_URL = "https://kms.pallycon.com/v2/cpix/pallycon/getKey/"
PALLYCON_ENC_TOKEN = 'PALLYCON_KMS_TOKEN'
# Request headers
headers = {'content-type': 'application/xml'}
...
- Request DRM keys from PallyCon. in this case it’s been configured for the Fairplay, Widevine and Playready for 1 SD key and 1 AUDIO key.
- Parse the PallyCon DRM response into the Pallycon_Drm_Config helper class
Step 2. Apply PallyCon DRM using Bitmovin CENC API
- After getting the PallyCon drm configs we first split the DRM config by tracks i.e SD/AUDIO
...
def get_drm_config_by_track(pallycon_drm_configs: typing.Dict, track: str) -> typing.Dict:
return dict(filter(lambda elem: (elem[1]).get_track() == track,pallycon_drm_configs.items()))
pallycon_drm_configs = _get_pallycon_drm_config()
audio_drm_configs = get_drm_config_by_track(pallycon_drm_configs, "AUDIO")
sd_drm_configs = get_drm_config_by_track(pallycon_drm_configs, "SD")
...
- Lastly we apply the
Pallycon_Drm_Config
and create the DRM Muxing by using the method _create_drm_config @ cenc_drm_content_protection.py
It’s THAT EASY!
FAQ
Question: Exception in _get_pallycon_drm_config @ cenc_drm_content_protection.py
Answer: This could be due to an
- expired PallyCon DRM token OR
- invalid request body
Kindly check with your PallyCon contact for more details.
Appendix
WORKING Source code
- Clone the Bitmovin GitHub repository
- use this updated cenc_drm_content_protection.py file w/ the PallyCon integation in place of the GitHub sample
Additional reads
- please visit the reference By PallyCon.