skifli
Backend Developer
I have the following code to record a screen in Python. However, the video generated is much faster than the record speed. Does anyone know how to slow the recording speed down?
Python:
from cv2 import VideoWriter, VideoWriter_fourcc, namedWindow, WINDOW_NORMAL, cvtColor, COLOR_BGR2RGB, imshow, waitKey, destroyAllWindows
from datetime import datetime
from pyautogui import screenshot
from numpy import array
recording = VideoWriter(f"{datetime.now().strftime('%d-%m-%Y-%H-%M-%S')}.mp4", VideoWriter_fourcc(*"mp4v"), 60.0, (1920, 1080))
namedWindow("Recording...", WINDOW_NORMAL)
while True:
frame = cvtColor(array(screenshot()), COLOR_BGR2RGB)
recording.write(frame)
imshow("Recording...", frame)
if waitKey(1) == ord("q"):
break
recording.release()
destroyAllWindows()