c++ - C 或 C++ 和 Linux 中的屏幕捕获程序

标签 c++ c screenshot

我正在寻找一个使用 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/

相关文章:

c++ - 线性规划 : Modulo constraint

c++ - 为什么 g++5 在自动类型推导中推导对象而不是 initializer_list

delphi - 如何在 TWebBrowser 中捕获页面区域?

java - 即时屏幕捕获 Java

javascript - phantomjs 和我的网络浏览器之间的渲染差异

c++ - Matlab Mex 代码未编译

c++ - visual studio 和 gcc 的 const 引用语法区别

c - C 中的 Pthreads。简单的示例不起作用

c - 使用双指针对字符串中的字母进行排序

c - C 中的可变长度数组是否以默认值 0 开头?