录像-游戏黑屏

时间:2019-12-27 14:27:23

标签: screenshot frame pyautogui

我正在使用pyautogui将屏幕截图制作为视频帧。当即时通讯捕获例如。浏览器一切正常。但是当我录制带有防热引擎的Tibia时,我只有这个应用程序的黑屏。 有什么方法可以从此应用获取屏幕的真实状态吗?

示例代码。

import cv2
import numpy as np
import pyautogui

# display screen resolution, get it from your OS settings
SCREEN_SIZE = (1920, 1080)
# define the codec
fourcc = cv2.VideoWriter_fourcc(*"XVID")
# create the video write object
out = cv2.VideoWriter("output.avi", fourcc, 20.0, (SCREEN_SIZE))

while True:
    # make a screenshot
    img = pyautogui.screenshot()
    # convert these pixels to a proper numpy array to work with OpenCV
    frame = np.array(img)
    # convert colors from BGR to RGB
    frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
    # write the frame
    out.write(frame)
    # show the frame
    cv2.imshow("screenshot", frame)
    # if the user clicks q, it exits
    if cv2.waitKey(1) == ord("q"):
        break

# make sure everything is closed when exited
cv2.destroyAllWindows()
out.release()

0 个答案:

没有答案
相关问题