-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScreenRecoder.py
More file actions
39 lines (31 loc) · 975 Bytes
/
Copy pathScreenRecoder.py
File metadata and controls
39 lines (31 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import cv2
import pyautogui
from win32api import GetSystemMetrics
import numpy as np
import time
# Screen dimensions
width = GetSystemMetrics(0)
height = GetSystemMetrics(1)
dim = (width, height)
# Video writer setup
f = cv2.VideoWriter_fourcc(*"XVID")
output = cv2.VideoWriter("VideoRecording.mp4", f, 30.0, dim)
# Duration and end time
now_start_time = time.time()
dur = 80 # Duration in seconds (change this to increase recording time)
end_time = now_start_time + dur
while True:
# Capture screenshot
image = pyautogui.screenshot()
frame = np.array(image)
# Since pyautogui returns an RGB image, we convert it to BGR
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
# Write the frame to the video file
output.write(frame)
# Check if duration has passed
c_time = time.time()
if c_time > end_time:
break
# Release the video writer
output.release()
print("____END___")