Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python record screen

import cv2
import numpy as np
import pyautogui
import keyboard

filename = "record"
screen_size = pyautogui.size()
codec = cv2.VideoWriter_fourcc(*'mp4v')
vid = cv2.VideoWriter(filename + '.mp4', codec, 20, screen_size)

print("Started recording")
while True:
    img = pyautogui.screenshot()
    img = np.array(img)
    frame = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    vid.write(frame)
    if keyboard.is_pressed('x'):
        break

cv2.destroyAllWindows()
vid.release()
 
PREVIOUS NEXT
Tagged: #python #record #screen
ADD COMMENT
Topic
Name
4+8 =