使用Gstreamer捕获屏幕并将其显示在窗口中? [英] Using Gstreamer to capture screen and show it in a window?

查看:499
本文介绍了使用Gstreamer捕获屏幕并将其显示在窗口中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要捕获第二个显示器的屏幕并在一个窗口内的主显示器中监视"它(缩放为x0.5并使用邻居内插法,因为我更喜欢性能而不是质量).通过这个链接,我得到了以下截屏命令:

I need to capture the screen of the second display and "monitor" it in the main display, inside a window (scaled at x0.5 and with neighbor interpolation because I prefer performance against quality). From this link, I've got this screencast command:

gst-launch ximagesrc ! ffmpegcolorspace ! queue \
! vp8enc quality=10 speed=2 ! mux. alsasrc ! audio/x-raw-int ! queue \
! audioconvert ! vorbisenc ! mux. webmmux name=mux \
! filesink location=screencast.webm

...但是它捕获到文件(不是窗口),缺少比例尺和插值类型,不需要声音等.

... but it capture to a file (not a window), it's missing the scale and interpolation type, the sounds is not necessary, etc.

正如我对libav的熟悉一样,我正在寻找的东西与此相似:

As I'm familiar with libav, what I'm looking for is something similar to this:

avconv -f x11grab -r 30 -s 1280x1024 -i :0.1 -c:v mpeg4 -b:v 1000k \
-vf "hflip" -vf "scale=640:480" -sws_flags "neighbor" -f avi - | avplay -i -

...我会用它,但是它在帧速率方面存在一些问题(询问

... I would use it, but it has some problems with the framerate (asked here). So, I'm looking for an alternative in Gstreamer.

推荐答案

以下是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).

这篇关于使用Gstreamer捕获屏幕并将其显示在窗口中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆