且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Gstreamer捕获屏幕并将其显示在窗口中?

更新时间:2023-12-03 15:52:22

以下是gst-launch命令:

Here is the gst-launch command:

gst-launch-1.0 ximagesrc startx=1280 use-damage=0 ! video/x-raw,framerate=30/1 ! videoscale method=0 ! video/x-raw,width=640,height=480  ! ximagesink

说明:

参数startx =从像素列" 1280开始记录-也就是说,如果有两个1280宽度的监视器,它将从右侧的一个开始.

parameter startx = start recording from "pixel column" 1280 - that is if you have two 1280 width monitors it will start with the one on the right side.

参数use-damage设置为0 =不要使用 XDamage .损坏仅计算后续帧之间的差异,这显然对CPU要求很高.

parameter use-damage set to 0 = do not use XDamage. damage counts only differences between subsequent frames which is apparantly quite CPU demanding.

元素ximagesink = X服务器创建的窗口作为输出-与glimagesink(opengl加速窗口)相比,它对CPU的要求更低.

element ximagesink = X server created window as output - its less CPU demanding than glimagesink (opengl accelerated window).

element videoscale参数method设置为0表示最接近的邻居,如Mario Mey在评论中建议的那样.这使我的CPU节省从17%降至12%.

element videoscale parameter method to 0 meaning nearest neighbor as suggested by Mario Mey in comment. This resulted for me in CPU save from 17% to 12%.

还有可配置的fps和显示窗口的高度/宽度(我认为它足够清晰).

There is also configurable fps and height/width of display window(I think its clear enough).