python中的屏幕记录器

2024-03-28 13:20:31 发布

您现在位置:Python中文网/ 问答频道 /正文

有没有用python制作屏幕记录器应用程序的库?我觉得这样做会很有趣。但是一个使用ubuntu在linux im上运行的库

谢谢!


Tags: 应用程序屏幕ubuntulinux记录器im
3条回答

我不知道用Python执行屏幕录制的机制。但是,您可以使用Python来控制现有的许多屏幕录制程序之一:

  • 记录
  • 记录桌面
  • 拜占庭
  • 伊斯坦布尔
  • vnc2swf型
  • pyvnc2swf型

对于使用python进行屏幕录制,使用MSS是一个很好的选择。

例如,使用http://python-mss.readthedocs.io/examples.html中的代码,我得到的平均fps为60。

import time
import cv2
import mss
import numpy


with mss.mss() as sct:
    # Part of the screen to capture
    monitor = {'top': 40, 'left': 0, 'width': 800, 'height': 640}

    while 'Screen capturing':
        last_time = time.time()

        # Get raw pixels from the screen, save it to a Numpy array
        img = numpy.array(sct.grab(monitor))

        # Display the picture
        cv2.imshow('OpenCV/Numpy normal', img)

        # Display the picture in grayscale
        # cv2.imshow('OpenCV/Numpy grayscale',
        # cv2.cvtColor(img, cv2.COLOR_BGRA2GRAY))

        print('fps: {0}'.format(1 / (time.time()-last_time)))

        # Press "q" to quit
        if cv2.waitKey(25) & 0xFF == ord('q'):
            cv2.destroyAllWindows()
            break

recordscreen.py是用于avconv的命令行选项包装器(以前用于ffmpeg)视频捕获/转换工具。在纯Python中实现这一点太慢了,但是当然您可以为那些工具创建有用的绑定,或者改进现有的绑定,比如AVBin

相关问题 更多 >