Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

iftekhs's avatar
Level 13

How can i encode my videos to make it difficult to steal.

Hi, first of all, I know that it is impossible to 100% block a user from downloading videos that are actually sent to them. But my question is how can I encode my videos in laravel in order to make it a bit difficult to steal?

0 likes
7 replies
tykus's avatar

Anyone who is working with video (like Laracasts) is using a third party like Vimeo; and even then preventing users from stealing the content is not bulletproof.

iftekhs's avatar
Level 13

Thank you for your comment!

Well, I guess I already told that I know it's not 100% possible to protect against video steal but I just want to know how can I encode a video in PHP? just to make it a bit more difficult to steal. :)

martinbean's avatar
Level 80

@iftekhs This has very little to do with Laravel to be honest. The techniques and steps you will use will be the same no matter what back-end language and framework you use.

I’ve ran a video streaming website since 2014. For optimum playback you’re going to want to create what’s called an HLS encoding. This is where the video file is chopped into multiple segments, and usually at different bitrates, so the video can with the least change of buffering. If you’ve ever watched a YouTube video and Netflix video and seen the video pixelate temporarily, that’s because the stream’s switched to a lower bitrate temporarily because of network congestion. It does this so the video can carry on playing—albeit at a lower resolution—rather than stop and buffer.

For protecting the video, you can encrypt these segments. That way, the video will only play if a key can be retrieved from your server. Because your server returns these encryption keys, you can use authentication and authorisation to determine if the user should be allowed to play the video or not (i.e. if it’s behind a subscription paywall).

I’ve worked a lot with video streaming on the web the past 8 years or so now and it’s an area I’m really passionate about. It just so happens that I’m literally in the process of creating a course on building a video streaming website using Laravel! So if it’s something you’re interested in then you can subscribe to a mailing list I’ve created where I’m sending updates on the course: https://www.getrevue.co/profile/martinbean.

If the course is something you’d be interested in, DM me on Twitter and I can send you a discount code for when the course launches (mid-May/early-June). It’ll cover essentially building a Laracasts or Netflix clone where videos can only be watched with an active subscription.

2 likes
iftekhs's avatar
Level 13

@martinbean Thank you for your comment. I think now I got an idea about how I can make the video more difficult to steal. Do you have any tutorials or know if there is any good tutorial on how I can implement hls encoding using PHP?

martinbean's avatar

@iftekhs Again, it’s not something you’d do in PHP. Transcoding the video file will be done using a command line utility like ffmpeg, or a service like AWS Elastic Transcoder or Mux.

1 like
iftekhs's avatar
Level 13

@martinbean Yes, I understand that now completely after researching a bit. Thank you so much for your reply :) Have a great day!

1 like

Please or to participate in this conversation.