Fairplay is the Apple DRM and was initially used only in the iTunes store to protect AAC encoded audio files but got soon also adopted for Apple’s video products that are now part of the iTunes store. Fairplay is specifically designed for Apple HTTP Live Streaming (HLS) with Apple playback devices such as iPhone, iPad, Apple TV and Mac OS X. Fairplay is also used as Content Decryption Module (CDM) of the Safari browser. This enables HTML5 native playback of DRM encrypted Fairplay streams without plugins in Safari.
This tutorial is based on this full example, which is using our Bitmovin PHP API client, however we do offer API clients in other languages as well. If you haven't created any encodings with our API clients yet, we recommend you to read the getting started guide called "Create an Encoding with our API" at first, before you continue.
Lets start with the preparation of required information we need in order to protect your content using Fairplay DRM. This values will be provided by your multi DRM licensing server provider such as Irdeto, EZDRM, ExpressPlay, Axinom, etc.
$fairPlayKey = "0123456789abcdef0123456789abcdef"; $fairPlayIV = "0123456789abcdef0123456789abcdef"; $fairPlayUri = "skd://userspecifc?custom=information";
The parameters of the Fairplay DRM configuration have the following meaning:
- fairPlayKey: You need to provide a key that will be used to encrypt the content (16 byte; 32 hexadecimal characters)
- fairPlayIV: The initialization vector is optional. If it is not provided we will generate one for you. (16 byte; 32 hexadecimal characters)
- fairPlayUri: If provided, this URI will be used for license acquisition
$tsMuxing1080p = createTsMuxing($apiClient, $encoding, $videoStream1080p, null, null); $audioTsMuxing128 = createTsMuxing($apiClient, $encoding, $audioEncodingStream128, null, null); $fairPlayEncodingOutput1080p = createEncodingOutput($output, $outputPath . 'video/1080p/hls/drm/'); $fairPlayDrm1080p = createFairPlayDrm($fairPlayKey, $fairPlayIV, $fairPlayUri, array($fairPlayEncodingOutput1080p)); $videoTsDrm1080p = $apiClient->encodings()->muxings($encoding)->tsMuxing()->drm($tsMuxing1080p)->fairplay()->create($fairPlayDrm1080p); $audioFairPlayEncodingOutput128 = createEncodingOutput($output, $outputPath . 'audio/128kbps/hls/drm/'); $audioFairPlayDrm128 = createFairPlayDrm($fairPlayKey, $fairPlayIV, $fairPlayUri, array($audioFairPlayEncodingOutput128)); $audioTsDrm128 = $apiClient->encodings()->muxings($encoding)->tsMuxing()->drm($audioTsMuxing128)->fairplay()->create($audioFairPlayDrm128);