Stream a lot of screenshots from the server

Let's say I have this tool that takes a screenshot of the user's desktop every 10 seconds and uploads images to the server. Images are deleted from the server after 24 hours. I want to allow the user to view these screenshots in my browser. So, let's say, each image is 300 thousand, and 5000 of them are downloaded in 24 hours - this is 1.5 GB of data. These are PNG images, and often one screenshot is not different from the previous one, so I think I could compress them pretty well - but I'm not sure how this will work. I want to allow the user to view these images in my browser. I want a slider under the images so that the user can go anywhere within 24 hours. I think something like a YouTube player would be perfect. Where the user can skip, and data streams, etc. Image quality is important because the user must be able to read text on screenshots. I would prefer a Python solution.

I had never done anything like this before, and I don’t know how to approach the problem. What would you do?

+6
source share
2 answers

Quick and easy solution -

  • drag the screen along the fixed grid
  • store fragments separately, indexed by a strong hash (to exclude duplicates, even between users)
  • save the whole screen as a 2-dimensional hash array.
  • restore the original screen in the browser from hashed fragments.

Switching from one screen to another, very similar, would be a matter of loading just a few fragments, so your compression there.

Implement a simple link counting scheme to remove tiles again. You might also want to share portions of the screen between users to further reduce storage.

Experiment with different tile sizes to see which one works best; this may depend on screen resolution, user activity, and the graphic format used to store items.

Image processing in Python can be done using PIL .

+5
source

If the user is currently on image K and wants to download image H, assuming the screenshots will be basically the same, you can simply send delta diff between H and K.

You can calculate the difference in advance and save them in a cache or database for faster access (but there will be a lot of data), or you can calculate it on the fly.

+1
source

Source: https://habr.com/ru/post/888262/


All Articles