You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import pyautogui
import cv2
import time
import numpy as np
def record_screen(filename, duration=30, width=1920, height=1080, fps=30):
fourcc = cv2.VideoWriter_fourcc(*'mp4v') # Video codec
out = cv2.VideoWriter(filename, fourcc, fps, (width, height))
start_time = time.time()
while time.time() - start_time < duration:
img = pyautogui.screenshot()
img = cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR)
out.write(img)
cv2.imshow('Screen Recorder', img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
out.release()
cv2.destroyAllWindows()
# Example usage:
filename = "test-01.mp4"
duration = 30 # Record for 30 seconds
record_screen(filename, duration)
when i run it, i get the screen recorded as displayed in the attached screenshot. what am i doing wrong and how to adjust the script so that the recording goes on until i stop it myself?
The text was updated successfully, but these errors were encountered:
Hello,
below is my script:
when i run it, i get the screen recorded as displayed in the attached screenshot. what am i doing wrong and how to adjust the script so that the recording goes on until i stop it myself?
The text was updated successfully, but these errors were encountered: