ponty / pyscreenshot

Python screenshot library, replacement for the Pillow ImageGrab module on Linux.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why so slow?

goncalopp opened this issue · comments

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.

Example for gtk

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

commented

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.

commented

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

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.

@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

commented

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.