Skip to content

Commit e4135bc

Browse files
committed
update screen recorder tutorial
1 parent 16ad39e commit e4135bc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

general/screen-recorder/screen_recorder.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
import numpy as np
33
import pyautogui
44

5-
# display screen resolution, get it from your OS settings
6-
SCREEN_SIZE = (1920, 1080)
5+
# display screen resolution, get it using pyautogui itself
6+
SCREEN_SIZE = tuple(pyautogui.size())
77
# define the codec
88
fourcc = cv2.VideoWriter_fourcc(*"XVID")
9+
# frames per second
10+
fps = 12.0
911
# create the video write object
10-
out = cv2.VideoWriter("output.avi", fourcc, 20.0, (SCREEN_SIZE))
12+
out = cv2.VideoWriter("output.avi", fourcc, fps, (SCREEN_SIZE))
13+
# the time you want to record in seconds
14+
record_seconds = 10
1115

12-
while True:
16+
for i in range(int(record_seconds * fps)):
1317
# make a screenshot
1418
img = pyautogui.screenshot()
1519
# convert these pixels to a proper numpy array to work with OpenCV

0 commit comments

Comments
 (0)