[英]How do I programmatically video record a window / GUI application in python?
I would like to video record a GUI application (specifically RViz) programmatically since I am running an experiment multiple times and would like to automate and synchronize those recordings with the run.我想以编程方式对 GUI 应用程序(特别是 RViz)进行视频录制,因为我正在多次运行实验,并希望将这些录制内容与运行自动化和同步。 RViz itself offers no recording service and recommends SimpleScreenRecorder.
RViz 本身不提供录制服务,推荐使用 SimpleScreenRecorder。 Are there any libraries that offer this functionality?
是否有提供此功能的库?
System: Linux (Ubuntu)系统:Linux(Ubuntu)
Preferred language: python首选语言:python
I didn't find any suitable tools so I wrote up my own that should work on all Linux systems: https://github.com/LemonPi/window_recorder我没有找到任何合适的工具,所以我自己写了一个应该适用于所有 Linux 系统的工具: https : //github.com/LemonPi/window_recorder
You use it as a context manager, supplying either no window names to prompt you to click a window, or a list of window names to attempt to capture (the first one that's valid gets matched).您将其用作上下文管理器,不提供窗口名称以提示您单击窗口,或者提供要尝试捕获的窗口名称列表(匹配第一个有效的名称)。 For example,
例如,
from window_recorder.recorder import WindowRecorder
import time
# passing in nothing as the window name will allow you to select the window by clicking
# want to capture an RViz window, which could have name "RViz*" as well
with WindowRecorder(["RViz*", "RViz"], frame_rate=30.0, name_suffix="rviz"):
# do things...
time.sleep(0.1)
start = time.time()
while time.time() - start < 2:
time.sleep(0.1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.