Advertisement
ikizid

screenrecorder.py

Jul 4th, 2025
227
0
26 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | Source Code | 0 0
  1. # FaceBook https://www.facebook.com/photo/?fbid=1180778040743079&set=a.456019453218945
  2. # pip install opencv-python pyautogui numpy keyboard
  3.  
  4. import cv2
  5. import numpy as np
  6. import pyautogui
  7. import keyboard
  8.  
  9. screen_size = pyautogui.size()
  10. fps = 20
  11. fourcc = cv2.VideoWriter_fourcc(*"XVID")
  12. output_file = "screen_recording-clcoding.mp4"
  13. out = cv2.VideoWriter(output_file, fourcc, fps,
  14.                       (screen_size.width, screen_size.height))
  15.  
  16. print("Recording... Press 'q' to stop.")
  17.  
  18. while True:
  19.     screen = pyautogui.screenshot()
  20.     frame = np.array(screen)
  21.     frame = cv2.cvtColor(frame, cv2,COLOR_FGB2BGR)
  22.     out.write(frame)
  23.    
  24.     if keyboard.is_pressed('q'):
  25.         print("Recording stopped")
  26.         break
  27.    
  28. out.release()
  29. print(f"Video saved to {output_file}")
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement