0

i want to record scenes from my screen, only keeping those that contain a certain pixelcolor. I have already written a screengrabber using python for this:

import PIL.ImageGrab 

def get_pixel_colour(i_x, i_y):
    return PIL.ImageGrab.grab().load()[i_x, i_y]   

print get_pixel_colour(0, 1)

i= 0 
while (True):
     i=i+1
     x = PIL.ImageGrab.grab()
     print i
     x.save("tm\screengrab"+ str(i) +".bmp")

The thing is my frames per second are not enough to produce a video. I would at least need 25 fps for that, i think. How can i improve the performance of my screengrabber so that it works? I want to keep python as production language, if possible, as i am not as adept in C++.

Is there something like a compiler for python perhaps?

Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
tarrasch
  • 2,630
  • 8
  • 37
  • 61

1 Answers1

0

How big is your screen?

If you want to screen grab a 1920x1080 screen at 25fps, and write to a bmp at 25fps you are going to need some much better hardware and probably a totally different software approach.

Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
  • i get my screen at a resolution of 1024x798. i hope to fix this with an optimization rather than new hardware. I can for example write to another harddisc, other than the system itself – tarrasch Dec 04 '11 at 00:30
  • That's still 60Mb/s which is high for a random write to a single disk - even assuming the PIL is efficient – Martin Beckett Dec 04 '11 at 00:44
  • i changed it now to jpg. see if that helps. Can you show me how to modify my code to show me the number of writes per second? – tarrasch Dec 04 '11 at 08:16