如何在PHP中实现明键视频加密并在HTML中播放 [英] How to implement Clear-Key video encryption in PHP and play it in HTML

查看:850
本文介绍了如何在PHP中实现明键视频加密并在HTML中播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在php中实现视频加密,并在HTML5视频中播放加密的视频.我已经阅读了一些相关文件:

我知道我可以使用其他工具和服务:

我想提供以下示例:

我应该通过什么步骤? 我在服务器端使用PHP(laravel).

解决方案

如果您想支持主要的常用DRM,则此时需要Widevine,PlayReady或FairPlay,那么您确实需要多DRM服务器或服务. /p>

如果您只需要基本保护,则可以使用AES加密或将其明显地与DASH结合使用.

这些安全性不高,但有时足以满足某些需求.

您可以使用ffmpeg和openssl创建AES加密的HLS流-ffmpeg文档( http://ffmpeg.org/ffmpeg-all.html#Options-34 )包含以下示例脚本:

 #!/bin/sh
BASE_URL=${1:-'.'}
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
 

您还可以使用mp4Box( https://gpac.wp.imt .fr/mp4box/encryption/common-encryption/)来创建基本的清晰DASH加密:

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

drm信息包含在drm_file.xml中,并在上面的链接中进行了解释.

I want to implement video encryption in php and play encrypted video in HTML5 video. I have read some documents about it:

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

I want to provide like this example:

What steps should I pass? 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:

#!/bin/sh
BASE_URL=${1:-'.'}
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.

这篇关于如何在PHP中实现明键视频加密并在HTML中播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆