问题
I want to implement video encryption in php
and play encrypted video in HTML5 video. I have read some documents about it:
- https://en.wikipedia.org/wiki/Encrypted_Media_Extensions
- https://w3c.github.io/encrypted-media/
And I know there are alternative tools and services that I can use:
- https://support.uplynk.com/tut_embedding_the_uplynk_player_3.html
- https://www.wowza.com/products/capabilities/streaming-content-security
- https://www.intertrust.com/products/drm-system/livestream/
- https://bitmovin.com/cenc-widevine-drm/
- https://www.html5rocks.com/en/tutorials/eme/basics/
I want to provide like this example:
- https://demo.castlabs.com/ (play big buck bunny smooth streaming : that can't be downloaded and the url is one-time usable)
What steps should I pass? I use PHP (laravel) in server-side.
回答1:
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.
来源:https://stackoverflow.com/questions/46362442/how-to-implement-clear-key-video-encryption-in-php-and-play-it-in-html