tencent cloud

Playing DRM-Encrypted Videos
Last updated: 2022-09-13 10:48:26
Playing DRM-Encrypted Videos
Last updated: 2022-09-13 10:48:26

Overview

This document shows you how to encrypt videos using DRM solutions and play the encrypted videos with a player.

Prerequisites

Before you start, do the following:

Activating VOD

Follow the steps below to activate VOD:
2. Purchase VOD services. For details, see Billing Overview.
3. Go to the VOD console.
At this point, you have activated VOD.

Obtaining FairPlay certificate information

Submitting the certificate information

Configuring the SDMC UID and key information

The example below shows how to enable key hotlink protection for the default distribution domain under your account:
Note:
We do not recommend enabling hotlink protection for a domain name already in use. Doing so may cause failure to play existing videos.
1. Log in to the VOD console, select Distribution and Playback > Domain Name on the left sidebar. Find the default distribution domain, click Set on the right, and select the Access Control tab.


2. Toggle on Key Hotlink Protection. In the pop-up window, click Generate to generate a random key (suppose it is vodtestkey). Copy the key and click Confirm. You will use the key later to generate player signatures.
image-KEY



Step 2. Encrypt a Video

1. In the VOD console, select Media Assets > Video/Audio Management on the left sidebar, select the target video (in this example, the file ID of the video encrypted is 387702304941991610), and click Process.



2. On the video processing page:
Select Task Flow as the Processing Type.
Select SDMC-WidevineFairPlayPreset as the Task Flow Template.

image-20220425192205432


Note:
SDMC-WidevineFairPlayPreset is a preset task flow. It uses the adaptive bitrate streaming template 31 or 41, the time point screenshot template 10 (for thumbnail generation), and the image sprite template 10.
The adaptive bitrate streaming template 31 generates multi-bitrate streams encrypted by FairPlay, and the adaptive bitrate streaming template 41 generates multi-bitrate streams encrypted by Widevine.
3. Click Confirm and wait until the Video Status changes from "Processing" to "Normal", which indicates that video processing is completed.


4. Click Manage in the Operation column of the video.
Under the Basic Info tab, you can view the thumbnail generated and outputs of adaptive bitrate streaming (template ID: 31 & 41).

image-20220426201159056


Under the Screenshot Info tab, you can view the image sprite generated (template ID: 10).

image-20220426201309975



Step 3. Generate a Player Signature

You will need the player signature to query past playback information. For directions on how to generate a player signature, see Superplayer Signature. For the example in this document, the payload for signature generation is as follows:
{
"appId": 1500014561,
"fileId": "387702304941991610",
"currentTimeStamp": 1661163373,
"expireTimeStamp": 2648557919,
"pcfg": "SDMC-advanceDrmPreset"
}
The key generated for the example in this document is vodtestkey, and the player signature (psign) generated is as follows:
eyJhbGciOiJIUzI1NiJ9.eyJhcHBJZCI6MTUwMDAxNDU2MSwiZmlsZUlkIjoiMzg3NzAyMzA0OTQxOTkxNjEwIiwiY3VycmVudFRpbWVTdGFtcCI6MTY2MTE2MzM3M
ywiZXhwaXJlVGltZVN0YW1wIjoyNjQ4NTU3OTE5LCJwY2ZnIjoiU0RNQy1hZHZhbmNlRHJtUHJlc2V0In0.BYdxHHEMH0isrta4ERmksGbfu4cLiwl7f1cu04XV890

Step 4. Play the DRM-Encrypted Video

Web

Using the VOD player

To play the DRM-encrypted video using the VOD player, just pass in the file ID of the video and your VOD account’s AppID when initializing the player.

Step 1. Import files

Import the player’s style file and script files into the webpage.
<link href="https://web.sdk.qcloud.com/player/tcplayer/release/v4.5.4/tcplayer.min.css" rel="stylesheet"/>

<script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.5.4/libs/TXLivePlayer-1.2.3.min.js"></script>

<script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.5.4/libs/hls.min.1.1.5.js"></script>

<script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.5.4/libs/flv.min.1.6.3.js"></script>

<script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.5.4/libs/dash.all.min.4.4.1.js"></script>

<script src="https://web.sdk.qcloud.com/player/tcplayer/release/v4.5.4/tcplayer.v4.5.4.min.js"></script>

Step 2. Add a player container

Add a player container to wherever you want to display the player:
<video id="player-container-id" width="414" height="270" preload="auto" playsinline webkit-playsinline>
</video>
Note:
You can customize the container ID as well as the height and width of the container.

Step 3. Add the initialization code

Add the following script to your page initialization code and pass in the required initialization parameters(including the Player Signature psign generated in Step 3):
var player = TCPlayer('player-container-id', {
appID: '1500014561' // The appID of your VOD account (required).
fileID: '387702304941991610', // The file ID of the video to play (required).
psign: 'eyJhbGciOiJIUzI1NiJ9.eyJhcHBJZCI6MTUwMDAxNDU2MSwiZmlsZUlkIjoiMzg3NzAyMzA0OTQxOTkxNjEwIiwiY3VycmVudFRpbWVTdGFtcCI6MTY2MTE2MzM3MywiZXhwaXJlVGltZVN0YW1wIjoyNjQ4NTU3OTE5LCJwY2ZnIjoiU0RNQy1hZHZhbmNlRHJtUHJlc2V0In0.BYdxHHEMH0isrta4ERmksGbfu4cLiwl7f1cu04XV890',
// For other parameters, see https://www.tencentcloud.com/document/product/266/39105
});

iOS

To play the DRM-encrypted video on iOS, refer to Integration Guide (Through FileId). You need to use the player signature (psign) generated in Step 3 (Generate a Player Signature).
Note:
Please submit a ticket for the player SDK that supports DRM.




Android

To play the DRM-encrypted video on Android, refer to Integration Guide (Through FileId). You need to use the player signature (psign) generated in Step 3 (Generate a Player Signature).
Note:
Please submit a ticket for the player SDK that supports DRM.




Summary

Now, you have learned how to encrypt videos using DRM solutions and play the encrypted videos in a player.
Note:
If you have any questions, please submit a ticket.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback