quasarstream / PHP-FFmpeg-video-streaming

📼 Package media content for online streaming(DASH and HLS) using FFmpeg
https://www.quasarstream.com/op/php/ffmpeg-streaming?u=php-ff
MIT License
514 stars 117 forks source link

I can't anti download from tool download #53

Closed HP161 closed 4 years ago

HP161 commented 4 years ago

I can't anti download from tool download. my code here: //A path you want to save a random key to your local machine $save_to = base_path() . '/lib/' . $randomString . '/key'; //A URL (or a path) to access the key on your website $url = url('/') . '/lib/enc.key'; // or $url = '/"PATH TO THE KEY DIRECTORY"/key'; $format = new Streaming\Format\X264(); $format->on('progress', function ($video, $format, $percentage) { echo sprintf("\rTranscoding...(%s%%) [%s%s]", $percentage, str_repeat('#', $percentage), str_repeat('-', (99 - $percentage))); }); $video->hls() ->x264() ->setFormat($format) ->encryption($save_to, $url, 1) ->autoGenerateRepresentations([720, 360]) // You can limit the numbers of representatons ->save(base_path() . '/lib/' . $randomString . '/' . $randomString . '.m3u8');

please help, thanks!

aminyazdanpanah commented 4 years ago

As I mentioned in the documentation, the encryption is not a full DRM solution.

You can use DRM systems such as Apple's FairPlay, Microsoft's PlayReady, and Google's Widevine to securely exchange keys and protect playback on devices.

If you do not want to use any DRM system, I recommend protecting your key on your server.

Personally I use a CSRF token to restrict access to the key(s) to only users on my website (it blocks any Download Manager software like IDM to access to the key).

You can also use this technique by József Koller on Medium.

HP161 commented 4 years ago

thanks @aminyazdanpanah