Why can't we simply write a script to collect all visible/lit pixels and create it into image? [closed]

As you know Netflix and Prime Video and others don't allow screenshots. But I'm having a hard time understanding why can't we write a script, maybe in JavaScript (and run in browser console) which reads the screen and the light intensity/color of each pixel of screen and then combine them to create an image i.e., screenshot?

After all, what we see in the video is basically pixels with some amount of light and colors. Isn't it possible?

Note: I know it's not legal to do this, but I'm just curious if it is possible or not. If possible, why people don't do it?


The amount of work to try and do this is completely beyond what is really "feasible". It also requires cooperation from the hardware that is processing the video.

You need to individually check upwards of 2 million individual pixels (1080p), then construct and format an image, then temporarily store that, then gather the next frame 33 milliseconds (30fps) later and repeat over and over again using JavaScript. JavaScript is already a relatively inefficient programming language and is working in a browser that is attempting to protect the user from webpages overstepping their boundaries.

Then there's the fact that the video is (most likely) being played in hardware on your graphics card using what is known as an "overlay". What that means is that your browser itself draws a black, or white, or green area and then simply tells the graphics card "here's some video data, decode it and display it over this space". The graphics card does the work and then overlays the video as one of the final steps before pushing the data out to the display.

Due to video protections that final step may potentially be at a point where your browser can't even request a true representative copy of that pixel at the point of display. It may well be that the video is only merged into the data stream as the part of the final display output that is protected by encryption.

As a result all that the JavaScript might see is a single solid colour painted over the area. Not entirely useful to capture.