pythonpython-3.xpython-mss

Faster screen capture


  1. Is it possible to capture the screen in gray? Will it speed up screen capture versus color capture?

If it speeds up the capture, it will be better than applying filters.


  1. Is it possible to record with more fps than monitor Hz?

For example: I have a 90Hz monitor, and now its max is 90fps. It possible to do so that with a monitor at 90Hz the recording was at 140fps?


3. Is there a library faster than mss?


Solution

  • For your first question i know that pyautogui have a function than do what you want called locateOnScreen chich can take a grayscale parameter to make it faster. For your third question i tried pyautogui which happened to be a little bit faster on every if you want to save the picture to a file and a lot faster if you don't want to.
    (done 250 tests)

    The code I used for my tests :

    import pyautogui
    import time
    import mss
    
    ITERATION = 50
    
    gui =[]
    msslist = []
    
    with mss.mss() as sct:
        for i in range(ITERATION):
    
            timer = time.time()
            im2 = pyautogui.screenshot('my_screenshot.png')
            gui.append(time.time()-timer)
            print("Temps pyautogui : {}".format(gui[i]))
    
            timer = time.time()
            filename = sct.shot()
            msslist.append(time.time()-timer)
            print("Temps mss : {}".format(msslist[i]))
    
    print(sum(gui)/ITERATION)
    print(sum(msslist)/ITERATION)