This repository was archived by the owner on Apr 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (27 loc) · 1.17 KB
/
main.py
File metadata and controls
36 lines (27 loc) · 1.17 KB
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
# Dependencies are managed in requirements.txt
from PIL import ImageGrab
from win32api import GetSystemMetrics
import cv2
# import the built in modules
import numpy as nV
import datetime
print('Created by Rajjit Laishram'[::1])
vidWidth = GetSystemMetrics(0)
vidHeight = GetSystemMetrics(1)
file_time_format = datetime.datetime.now().strftime('%Y-%m-%d %H-%M-%S')
saved_file = f'{file_time_format}.mp4'
fileName = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
recorded_video = cv2.VideoWriter(saved_file, fileName, 30.0, (vidWidth, vidHeight))
# for_webCam = cv2.VideoCapture(0)
while True:
vid = ImageGrab.grab(bbox=(0,0, vidWidth, vidHeight))
vid_nV = nV.array(vid)
vid_res = cv2.cvtColor(vid_nV, cv2.COLOR_BGR2RGB)
# _, wC_frame = for_webCam.read()
# wC_height, wC_width, _ = wC_frame.shape
# vid_res[0:wC_height, 0: wC_width, :] = wC_frame[0: wC_height, 0:wC_width, :]
cv2.imshow('RJs Screen Recorder', vid_res)
# cv2.imshow('RJs WebCam Recorder', wC_frame)
recorded_video.write(vid_res)
if cv2.waitKey(10) == ord('x'):
break