Screen Recorder

 import datetime


from PIL import ImageGrab
import numpy as np
import cv2
from win32api import GetSystemMetrics

width = GetSystemMetrics(0)
height = GetSystemMetrics(1)
time_stamp = datetime.datetime.now().strftime('%Y-%m-%d %H-%M-%S')
file_name = f'{time_stamp}.mp4'
fourcc = cv2.VideoWriter_fourcc('m''p''4''v')
captured_video = cv2.VideoWriter(file_namefourcc20.0, (widthheight))

webcam = cv2.VideoCapture(0)

while True:
    img = ImageGrab.grab(bbox=(00widthheight))
    img_np = np.array(img)
    img_final = cv2.cvtColor(img_npcv2.COLOR_BGR2RGB)
    _frame = webcam.read()
    fr_heightfr_width_ = frame.shape
    img_final[0:fr_height0fr_width, :] = frame[0fr_height0fr_width, :]
    cv2.imshow('Secret Capture'img_final)

    #cv2.imshow('webcam', frame)

    captured_video.write(img_final)
    if cv2.waitKey(10) == ord('q'):
        break

Comments

Popular Posts