Digital rights management, or you could just refer to it as DRM, is a way of controlling what users can do with some sort of digital content.
To protect the content, the decryption key is stored in a license server, then the player gets the license key from the license server to decrypt the content. As you can see the image below, CDM (Content Decryption Module) is required to play DRM contents.
There is a situation where multiple keys are used for a single content, like one for the video segments and the other for the audio segments. In this case, while you can keep contents safer, you have to handle multiple keys during the playback.
In this article, I will use Clearkey as an example. Clearkey is one of the DRM schemes, and the main difference between clearkey and the ‘normal’ DRM’s (Widevine, Playready, FairPlay) is that it doesn’t offer the same security level as well as the other DRM schemes and clearkey uses a ‘clear’ key without encrypting the key itself.
prepare key and kid
Let’s prepare keys(random 16bytes) and kids(random 16bytes) for audio and video segments.
$ date | md5
eecdb2b549f02a7c97ce50c17f494ca0 // key for video$ date | md5
c77fee35e51fd615a7b91afcb1091c5e // kid for video$ date | md5
9abb7ab6cc4ad3b86c2193dadb1e786c // key for audio$ date | md5
045f7ecc35848ed7b3c012ea7614422f // kid for audio
Encrypt fragmented mp4
Once you have keys and kids, you are ready to encrypt the content.
$ mp4fragment sample.mp4 sample_fragmented.mp4// encryption
$ mp4encrypt --method MPEG-CENC --key 1:[video_key]:random --property 1:KID:[video_kid] --key 2:[audio_key]:random --property 1:KID:[audio_kid] --global-option mpeg-cenc.eme-pssh:true sample_fragmented.mp4 sample_fragmented_encrypted.mp4// dash
$ mp4dash --use-segment-timeline sample_fragmented_encrypted.mp4
Add ContentProtection to mpd
<CntentProtection> tags so that ExoPlayer requests the key for each video and audio.
Now you are ready to play multi-key DRM contents.
In the next article, I will show you how to play this content with ExoPlayer.
“Play Multi-key DRM contents on ExoPlayer (part-2)” by Taku Semba