ponty / pyscreenshot

Python screenshot library, replacement for the Pillow ImageGrab module on Linux.
BSD 2-Clause "Simplified" License
499 stars 89 forks source link

Why so slow? #29

Closed gitanat closed 7 years ago

gitanat commented 8 years ago

Is there any reason for the backend code to be structured around writing to files? And also on a separate process? For backends that don't need it (gtk, qt, ...?), it seems performance would be hundreds/thousands of times better if operations are done in memory.

gitanat commented 8 years ago

Example for gtk

px=gtkbuffer.get_pixels() im= Image.frombytes('RGB', (width, height), px)

ponty commented 8 years ago

The only reason is that the original code was only for files, and it was easier just wrap all of them with the same function. I don't plan now to reimplement with direct functions, because I don't know the back-ends, I just wrapped existing code from others. But any improvements as pull requests are welcome.

ponty commented 8 years ago

Without separate process there was errors sometimes: #26 #27 I didn't find a better solution.

ghost commented 8 years ago

Any hints to make capture screenshot in Linux as fast as possible? I would like to be able to process it in real time, so I need to captures at a high FPS.

gitanat commented 8 years ago

@melonista I cobbled up something that was a bit faster, based in my previous comment but have since stopped working on it. I'll try to find it tomorrow and push to my fork

It might not be enough to give you "high" FPS, though, depending on your definition of high. I think I got a couple per second, IIRC less than 10

ponty commented 8 years ago

Check the documentation for performance: http://pyscreenshot.readthedocs.io/en/latest/ You can get maybe 10 fps with pyscreenshot. You may need a video recorder like Byzanz for better performance.