Screen Recorder Python Program
In this program, we are going to build a python program for creating a screen recorder.
# install package pip install opencv-python
Program -
import cv2
import numpy as np
from PIL import ImageGrab
def screenRecorder():
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter("output.avi", fourcc, 5.0, (1920, 1080))
while True:
img = ImageGrab.grab()
img_np = np.array(img)
frame = cv2.cvtColor(img_np, cv2.COLOR_BGR2RGB)
cv2.imshow("Screen Recorder", frame)
out.write(frame)
if cv2.waitKey(1) == 27:
break
out.release()
cv2.destroyAllWindows()
screenRecorder()
0 Comments