Home » Php » How to implement DRM in HTML5

How to implement DRM in HTML5

Posted by: admin October 27, 2017 Leave a comment


I want to implement DRM in HTML5 video (EME). I know it is supported in modern browsers:

And I know there are tools and services that I can use:

I want to provide like this example:

Do I have to use a service or I can implement client-side and server-side both on my own server? If I can implement client-side and server-side both, how could I do that?
I use PHP (laravel) in server-side.


If you want to support the major commonly used DRM’s, at this time Widevine, PlayReady or FairPlay then you do need either a multi-DRM server or service.

If you just want basic protection the you could use AES encryption or clearly with DASH.

These are not as secure but are sometimes good enough for certain needs.

You can use ffmpeg and openssl to create an AES encrypted HLS stream – the ffmpeg documentation (http://ffmpeg.org/ffmpeg-all.html#Options-34) includes this example script:

openssl rand 16 > file.key
echo $BASE_URL/file.key > file.keyinfo
echo file.key >> file.keyinfo
echo $(openssl rand -hex 16) >> file.keyinfo
ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags delete_segments \
  -hls_key_info_file file.keyinfo out.m3u8

You can also use mp4Box (https://gpac.wp.imt.fr/mp4box/encryption/common-encryption/) to create basic clear DASH encryptions:

MP4Box -crypt drm_file.xml movie.mp4 -out movie_encrypted.mp4

The drm info is included in the drm_file.xml and is explained at the link above.

Leave a Reply

Your email address will not be published. Required fields are marked *