提问人:Пётр 提问时间:11/18/2023 最后编辑:TugayПётр 更新时间:11/18/2023 访问量:54
使用 opencv、pyautogui 和 numpy 从屏幕上录制的视频比原始视频更快或更慢
Video recorded from screen using opencv, pyautogui and numpy is faster than the original or slower
问:
我试图在python上编写一个程序来记录屏幕。但是我遇到了一个问题,即输出比原始速度快。我试图更改 fps 值或延迟帧录制,但没有帮助。请帮帮我。下面是我的代码
import pyautogui
import cv2
import numpy as np
resolution = (1920, 1080)
codec = cv2.VideoWriter_fourcc(*"XVID")
filename = "Recording.avi"
fps = 20.0
out = cv2.VideoWriter(filename, codec, fps, resolution)
cv2.namedWindow("Live", cv2.WINDOW_NORMAL)
cv2.resizeWindow("Live", 480, 270)
while True:
img = pyautogui.screenshot()
frame = np.array(img)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
out.write(frame)
cv2.imshow('Live', frame)
if cv2.waitKey(1) == ord('q'):
break
out.release()
cv2.destroyAllWindows()
答: 暂无答案
评论
VideoWriter