我正在寻找一个使用 C 或 Cpp 在 Linux 中捕获屏幕的程序。有人可以帮忙提供一个框架结构或程序来帮助我吗?
感谢和问候。
最佳答案
How to capture screen with ffmpeg:
Use the x11grab device:
ffmpeg -f x11grab -r 25 -s 1024x768 -i :0.0+100,200 output.flv
This will grab the image from desktop, starting with the upper-left corner at (x=100, y=200) with the width and height of 1024x768.
If you need audio too, you can use alsa like this:
ffmpeg -f x11grab -r 25 -s 1024x768 -i :0.0+100,200 -f alsa -ac 2 -i pulse output.flv
因此,您只需将其放入 capture.sh
中并从代码中运行它即可:
#include <cstdlib>
int main(){ std::system("./capture.sh"); }
如果您必须在不调用外部实用程序的情况下执行此操作,则可以使用 libffmpeg directly.
关于c++ - C 或 C++ 和 Linux 中的屏幕捕获程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16933148/