May Sale! All accounts are 40% off this week.

Michael Fayez's avatar

How to prevent Screen RECORDING for video

Hello Best devs, How to prevent screen recording not only screen shot, screen recording from happing at all on the pc, or when happens the screen becomes black, my customer asked me for doing something like that in LMS, and show me a video for a website download plugin prevent users from screen recoding while you open the video ??? please help me Thanks in advance,,

0 likes
3 replies
LaryAI's avatar
Level 58

Preventing screen recording is a challenging task because it involves controlling the user's hardware and software environment, which is generally outside the scope of what a web application can do. However, there are some strategies you can employ to make it more difficult for users to record your content. Here are a few approaches:

1. DRM (Digital Rights Management)

Using DRM technologies can help protect your video content. Services like Widevine, PlayReady, and FairPlay can be integrated to provide a layer of protection.

2. Watermarking

You can add dynamic watermarks to your videos that include user-specific information (like their username or email). This won't prevent recording but can deter users from sharing recorded content.

3. JavaScript Techniques

You can use JavaScript to detect certain screen recording tools, although this is not foolproof.

Example Code

Here's an example of how you might use JavaScript to detect if the user is trying to record the screen using the visibilitychange event:

document.addEventListener('visibilitychange', function() {
    if (document.hidden) {
        alert('Screen recording detected! Please stop recording.');
        // You can also pause the video or take other actions here
        var video = document.getElementById('myVideo');
        if (video) {
            video.pause();
        }
    }
});

4. CSS Techniques

You can use CSS to make it harder to record by overlaying a transparent layer over the video. This won't prevent recording but can make it less effective.

<div class="video-container">
    <video id="myVideo" controls>
        <source src="your-video.mp4" type="video/mp4">
        Your browser does not support the video tag.
    </video>
    <div class="overlay"></div>
</div>

<style>
.video-container {
    position: relative;
    width: 100%;
    max-width: 600px;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5); /* Adjust transparency as needed */
    pointer-events: none;
}
</style>

5. Server-Side Techniques

You can monitor for unusual activity on the server side, such as multiple requests for the same video from different IP addresses, and take action accordingly.

Conclusion

While it's impossible to completely prevent screen recording, combining these techniques can help you make it more difficult and less appealing for users to record your content. Always remember that the more barriers you put up, the more you might also inconvenience legitimate users, so balance is key.

If you need a robust solution, consider consulting with a security expert who can help you implement a comprehensive strategy tailored to your specific needs.

Tray2's avatar

Not really possible, there are always ways to go around such things. You can basically just make it harder for ppl, but never stop it completely.

martinbean's avatar

@michael fayez You need to implement DRM.

I use a platform called Mux that recently introduced DRM. This uses the same technology as the likes of Netflix that will replace the video with a black square when trying to take a screenshot or screen recording.

Please or to participate in this conversation.