python-mss icon indicating copy to clipboard operation
python-mss copied to clipboard

How to capture the screen with a specific fps?

Open hcao720 opened this issue 5 years ago • 2 comments

Is there any way to capture the screen with a specific fps by applying mss?

hcao720 avatar Aug 16 '20 12:08 hcao720

This better belongs on StackOverflow, but I'll answer the question anyways.

In order to run a python loop at a certain FPS, you can delay based on the time taken for a process.

import time
MAX_FPS=60
MIN_FRAME_TIME=1/MAX_FPS

while True:
  start = time.time()
  # screen capture
  time.sleep(max(0, MIN_FRAME_TIME - (time.time() - start)))

Hope this helps :)

sagarreddypatil avatar Oct 22 '20 02:10 sagarreddypatil

Thanks!!!☺️

在 2020年10月22日,10:41,Sagar Patil [email protected] 写道:



This better belongs on StackOverflow, but I'll answer the question anyways.

In order to run a python loop at a certain FPS, you can delay based on the time taken for a process.

import time MAX_FPS=60 MIN_FRAME_TIME=1/MAX_FPS

while True: start = time.time()

screen capture

time.sleep(max(0, MIN_FRAME_TIME - (time.time() - start)))

Hope this helps :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/BoboTiG/python-mss/issues/181#issuecomment-714184895, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMY3RA3NXH4XAJOTNG7FVRTSL6LWDANCNFSM4QAZVOZA.

hcao720 avatar Oct 22 '20 04:10 hcao720