PHPackages                             sy-records/vod-hls - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. sy-records/vod-hls

ActiveLibrary[Image &amp; Media](/categories/media)

sy-records/vod-hls
==================

Tencent cloud video HLS encryption.

v1.0.0(6y ago)1222PHP

Since Sep 8Pushed 6y ago1 watchersCompare

[ Source](https://github.com/sy-records/vod-hls)[ Packagist](https://packagist.org/packages/sy-records/vod-hls)[ Docs](https://github.com/sy-records/vod-hls)[ RSS](/packages/sy-records-vod-hls/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

腾讯云云点播使用 HLS 加密
---------------

[](#腾讯云云点播使用-hls-加密)

### 安装

[](#安装)

```
composer require sy-records/vod-hls
```

### 加密过程

[](#加密过程)

1. [创建 HLS 普通加密模板](https://cloud.tencent.com/document/product/266/35167)
2. [对需加密视频进行加密转码](https://cloud.tencent.com/document/product/266/9642)
3. 前端利用 tcplayer（或者超级播放器）播放视频；
4. 播放器自动请求 [getkeyurl 获取 dk](https://cloud.tencent.com/document/product/266/9643)，getkeyurl 根据业务侧逻辑确认是否返回 dk；
5. 成功返回 dk 播放器自动解码播放。

### 使用方法

[](#使用方法)

#### 1. 创建 HLS 普通加密模板

[](#1-创建-hls-普通加密模板)

```
/**
 * 创建 HLS 普通加密模板
 * @url https://cloud.tencent.com/document/product/266/35167
 */
$config = [
    "Action" => "CreateSimpleAesTemplate", // 接口指令的名称
    "get_key_url" => "", // HLS 普通加密模板的 GetKeyURL 必须https
    "Region" => "", // 区域参数
    "Timestamp" => time(), // 当前 UNIX 时间戳
    "Nonce" => uniqid(), // 随机正整数，与 Timestamp 联合起来, 用于防止重放攻击
    "SecretId" => "", // 由腾讯云平台上申请的标识身份的 SecretId
];

$secretKey = ""; // 由腾讯云平台上申请的标识身份的SecretKey 需要生成签名

$data = Core::getCloudData($config, $secretKey);
```

#### 2. 通过 ProcessFile 接口发起视频加密

[](#2-通过-processfile-接口发起视频加密)

```
/**
 * 通过 ProcessFile 接口发起视频加密
 * @url https://cloud.tencent.com/document/product/266/9642
 */
$config = [
	"Action" => "ProcessFile",
	"fileId" => "", // 文件 ID
	"transcode.definition.0" => 230, // 转码输出模板号
	"transcode.drm.definition" => 10, // 视频加密控制参数，加密方式；
	"Region" => "", // 区域参数
	"Timestamp" => time(), // 当前 UNIX 时间戳
	"Nonce" => uniqid(), // 随机正整数，与 Timestamp 联合起来, 用于防止重放攻击
	"SecretId" => "", // 由腾讯云平台上申请的标识身份的 SecretId
	"notifyMode" => "Finish" // 任务流状态变更通知模式任务流状态变更通知模式。
];

$secretKey = ""; // 由腾讯云平台上申请的标识身份的SecretKey 需要生成签名

$data = Core::getCloudData($config, $secretKey);
```

### 3. 获取视频信息（获取EDK）

[](#3-获取视频信息获取edk)

> 获取 EDK 时，drm 内容需要在视频转码完成后获取，需要依靠 [视频转码完成回调](https://cloud.tencent.com/document/product/266/7832) ，或多次请求 `GetVideoInfo`

```
/**
 * 获取视频信息
 * @url https://cloud.tencent.com/document/product/266/8586
 */
$config = [
	"Action" => "GetVideoInfo",
	"fileId" => "", // 文件 ID
	"Region" => "", // 区域参数
	"Timestamp" => time(), // 当前 UNIX 时间戳
	"Nonce" => uniqid(), // 随机正整数，与 Timestamp 联合起来, 用于防止重放攻击
	"SecretId" => "", // 由腾讯云平台上申请的标识身份的 SecretId
	"notifyMode" => "Finish" // 任务流状态变更通知模式任务流状态变更通知模式。
];

$secretKey = ""; // 由腾讯云平台上申请的标识身份的SecretKey 需要生成签名

$data = Core::getCloudData($config, $secretKey);
```

### 4. 根据业务侧逻辑确认是否返回 dk

[](#4-根据业务侧逻辑确认是否返回-dk)

```
/**
 * getkeyurl获取dk
 * @url https://cloud.tencent.com/document/product/266/9643
 */
$config = [
	"Action" => "DescribeDrmDataKey",
	"edkList.0" => "", // 视频edk
	"Region" => "", // 区域参数
	"Timestamp" => time(), // 当前 UNIX 时间戳
	"Nonce" => uniqid(), // 随机正整数，与 Timestamp 联合起来, 用于防止重放攻击
	"SecretId" => "", // 由腾讯云平台上申请的标识身份的 SecretId
];

$secretKey = ""; // 由腾讯云平台上申请的标识身份的SecretKey 需要生成签名

$data = Core::getCloudData($config, $secretKey);

$res = json_decode($data,true);

// 需要进行decode还原为二进制
echo base64_decode($res['data']['keyList'][0]['dk']);
```

> EDK 和 DK 关系一一对应，可直接缓存

至此，业务方成功返回 dk，播放器自动解码播放 🎉

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2438d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/17615e789eec7042f64c6f4e8733421987d98fcdc4269395b42d2a7f0ae94301?d=identicon)[sy-records](/maintainers/sy-records)

---

Top Contributors

[![sy-records](https://avatars.githubusercontent.com/u/33931153?v=4)](https://github.com/sy-records "sy-records (16 commits)")

---

Tags

videovodhlstencent

### Embed Badge

![Health badge](/badges/sy-records-vod-hls/health.svg)

```
[![Health](https://phpackages.com/badges/sy-records-vod-hls/health.svg)](https://phpackages.com/packages/sy-records-vod-hls)
```

###  Alternatives

[php-ffmpeg/php-ffmpeg

FFMpeg PHP, an Object Oriented library to communicate with AVconv / ffmpeg

5.0k21.7M165](/packages/php-ffmpeg-php-ffmpeg)[vimeo/vimeo-api

Official PHP library for the Vimeo API.

4637.1M32](/packages/vimeo-vimeo-api)[vimeo/laravel

A Vimeo bridge for Laravel

4161.5M4](/packages/vimeo-laravel)[opentok/opentok

OpenTok is a platform for creating real time streaming video applications, created by TokBox.

1413.0M10](/packages/opentok-opentok)[mostafaznv/nova-video

Video Field for Laravel Nova

22398.0k1](/packages/mostafaznv-nova-video)[aminyazdanpanah/php-shaka

Shaka PHP is a library that uses Shaka Packager for DASH and HLS packaging and encryption, supporting Common Encryption for Widevine and other DRM Systems.

939.0k1](/packages/aminyazdanpanah-php-shaka)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
