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()
- Go to Python directory
- If you have Pygame skip this step otherwise open a terminal and type: pip install pygame
- In your Python files go to Python/Lib/site_packages/Pygame/examples
for screen-related things go to the 'camera' file
for the audio-related stuff go to the 'audiocapture' file