Using the following code:
import cv2
import numpy as np
from win32api import GetSystemMetrics # screen size
import elapsed
import datetime
screen_width = GetSystemMetrics (0)
screen_height = GetSystemMetrics (1)
resolution = (screen_width, screen_height)
codec = cv2.VideoWriter_fourcc(*'x264')
filename = ".\\screen_video.mp4"
fps = 30.0
out = cv2.VideoWriter(filename, codec, fps, resolution)
record_timer = datetime.datetime.now()
while True:
img = pyautogui.screenshot()
frame = np.array(img)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
out.write(frame)
if elapsed.get (record_timer ).seconds >= 30: break
out.release()
I am recording a 30 sec video of my screen.
Problem is: the recorded video speed is incorrect. It is just too fast. To be precise, instead of a 30 sec normal video, the result is a 6 seconds video. It is not lagging, I mean all content recorded correctly, just in a "fast forward" way.
I check these solutions, but did not solved my problem: The output of cv2.VideoWriter is incorrect. It's faster
Can you help me please what can be the problem here? Many thanks in advance for any concrete help!