Hi guys i'm building a screen recorder, it works and it creates the "output" video of the screen recording but there is one problem, when i run the program i notice a lot of frame drops when i drag and move a window for example, and in the final file, the video output, the FPS are not right i mean there are lags every time i move a window when i watch the final video, i tried to change the "fps" value of the program but the frame drops still remain, i have a monitor with 1920x1080 resolution with 120 fps so it's very smooth, how to solve this in order to have a fluid output video? Thanks a lot
import cv2
import numpy as np
from PIL import ImageGrab
def screenRec():
fourcc = cv2.VideoWriter_fourcc(*"XVID")
fps = 8.0
out = cv2.VideoWriter("output.mp4",fourcc,fps,(1920,1080))
while (True):
img = ImageGrab.grab()
img_np = np.array(img)
frame = cv2.cvtColor(img_np, cv2.COLOR_BGR2RGB)
out.write(frame)
screenRec()