Skip to content

diyeddin/clearkey-drm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ClearKey DRM With Shaka Player

This tutorial explains how to encode videos with HLS and encrypt them using ClearKeys and set up a ClearKey DRM Server to provide licenses for the video player.

Getting Started

This tutorial is based around the go-clearkey-server implementation.

Prerequisites

Installing

  • Shaka Player

    Clone the Shaka Player from the official repository and compile it according to the documentation.

  • Shaka Packager

    Download the binary file and rename it to packager and add it to PATH.

  • Go

    Install the Go language according to the documentation.

  • ClearKey

    Clone the forked repository of ClearKey Server and compile it.

    cd ~/go-clearkey-server
    go run .
  • Docker

    Follow the documentation to install the Docker Engine.

  • Docker Compose

    Download the appropriate release of Docker Compose, rename it to docker-compose and move it to /usr/local/bin (for Linux users).

  • Psycopg Library

    pip install psycopg2

Usage

After installing all the required packages let's start by creating the PostgreSQL database by running docker-compose in the ClearKey server directory:

cd ~/go-clearkey-server
sudo docker-compose up -d

Now our PSQL server is running and ready to recieve connections.

To run the ClearKey Server we change to the servers directory and run this command:

cd ~/go-clearkey-server
go run .

Now our DRM Server is running and connected to our database. We can check that by going to http://localhost:8080/license, we should start seeing the licenses if there's data in the database. Example Data

To HLS encode videos and encrypt them we can use encode.py that is provided in this repository. This script automates the encoding process and sends the encryption keys to the database. It's used as below:

python3 encode.py input_video.mp4 out_name

It should output the keyId and key values that it encoded the video with.

Now the ClearKey Server should be able to see the keyId and key pair and should provide the video player with the appropriate license.

This repository provides a website and its javascript code to test the video player. Make sure to provide the compiled shaka-player and the encoded video playlist in the same directory as the website.

Examples

Example request payload of Shaka Player

Example Payload

Example response from ClearKey server

As you can see here, the response is according to the W3C specifications. Example Response

What appears in the ClearKey server log after refreshing the website

Here the server is selecting the corresponding key for the requested key id Server Log

Acknowledgments

  • A special thanks to the original owner of the ClearKey Server implementation!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published