From bb27449e645b8036545ebd91a1706789336aac17 Mon Sep 17 00:00:00 2001 From: Jayanth-BS <109243649+Jayanth-BS@users.noreply.github.com> Date: Tue, 21 Nov 2023 19:24:40 +0530 Subject: [PATCH] Create Screen_rec.py --- Screen_Recorder/Screen_rec.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Screen_Recorder/Screen_rec.py diff --git a/Screen_Recorder/Screen_rec.py b/Screen_Recorder/Screen_rec.py new file mode 100644 index 00000000..22c614e9 --- /dev/null +++ b/Screen_Recorder/Screen_rec.py @@ -0,0 +1,25 @@ +#importin the packages +import cv2 +import pyautogui +import numpy as np + +#Set the parameters +screen_width, screen_height = pyautogui.size() +resolution = (screen_width, screen_height) +fps = 30 +rec_time = 5; +opname = "Sample.mp4" + +#Initialise parameters for the VideoWriter class +fourcc = cv2.VideoWriter_fourcc(*"mp4v") +out = cv2.VideoWriter(opname, fourcc, fps, resolution) + +#Extract the frames and display them at the specified rate +for _ in range(int(rec_time* fps)): + x = pyautogui.screenshot() + frame = np.array(x) + frame = cv2.cvtColor(frame,cv2.COLOR_RGB2BGR) + out.write(frame) + +End the Screen recording and save the video +out.release();