How to make Screen recorder using python
In this post i should teach you how to Make Screen recorder using python programming language
Yaa, its possible to build a screen recorder Using python pyautogui, cv2 , numpy , libraries
For this we need these library
for that we need to install it in terminal by using :-
pip install pyautogui
pip install cv2
pip install numpy
Now lets start ,
Copy the following simple source Code :-
___________________________________
# importing the required packages
import pyautogui
import cv2
import numpy as np
# Specify resolution
resolution = (1920, 1080)
# specify video codec
codec = cv2.VideoWriter_fourcc(*"XVID")
# specify name of output file
filename = "recordings.avi"
# specify frame rate
fps = 60.0
# creating a videowriter object
out = cv2.VideoWriter(filename, codec, fps, resolution)
#create an empty window
cv2.namedWindow("Live", cv2.WINDOW_NORMAL)
#Resize the window
cv2.resizeWindows("Live", 480, 270)
while True:
#Take screenshots using pyAutoGUI
img = pyautogui.screenshot()
#convert the screenshot in Numpy array
frame = np.array(img)
#Convert it from BGR to RGB
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
#Write it to output file
out.write(frame)
#optional display the recorded screen
cv2.imshow('Live', frame)
#stop recording when press Q
if cv2.waitKey(1) == ord('q'):
break
#Release the video writter
out.release()
#Destroy all windows
cv2 destroyAllWindows()
____________________________
stop Your screen record by pressing letter "q"
Thanks for your visit
---- Haneen the CREATE

