采用gst-launch命令进行linux屏幕录制

系统: fedora18
内核:3.8.0
平台:intel

一、直接通过工具录制:

采用第三方软件recordmydesktop,生成ogv视频文件,用ffmpeg转码为h264格式,再通过gst-launch-1.0或者mplayer播放,步骤如下:

1. recordmydesktop -o test.ogv --overwrite
2. ffmpeg -i test.ogv -f h264 test.mp4
3. gst-launch-1.0 playbin video-sink=vaapisink uri=file:///root/test.mp4 或 mplayer test.mp4

二、通过gstreamer的gst-launch命令

1.gstreamer 0.10 版本执行命令

gst-launch-0.10 ximagesrc use-damage=0 !
video/x-raw-rgb,framerate=15/1 ! ffmpegcolorspace ! x264enc !
matroskamux ! filesink location=”test.mkv”

2.gstreamer 1.0 版本执行命令

gst-launch-1.0 ximagesrc remote=1 use-damage=0 !
video/x-raw,framerate=15/1 ! videoconvert ! x264enc ! matroskamux ! filesink location=/root/capscreen/test.mkv

***: 如果录到的视频是黑框或者录制提示内存分配失败,需要加上remote=1参数,这是因为fedora存在的一个bug,fedora默认安装gst时没有打上shm选项:

https://bugzilla.redhat.com/show_bug.cgi?id=1136317
https://bugzilla.gnome.org/show_bug.cgi?id=721220

1.0版本和0.1版本区别,详细看:

https://cgit.freedesktop.org/gstreamer/gstreamer/plain/docs/random/porting-to-1.0.txt

3.以上是采用x264enc软编码的方式将屏幕视频源ximagesrc经过插件video/x-raw格式化后,送到h264软件编码插件,然后通过mux整流插件进入文件处理filesink插件,下面是硬件编码的方式,采用gst-vaapi包,https://github.com/01org/gstreamer-vaapi中的h264硬件编码器:

gst-launch-1.0 -e ximagesrc remote=1 ! videoconvert !
video/x-raw,format=YUY2,framerate=2/1,width=1024,height=768 ! tee name=enc ! queue ! vaapipostproc enc. ! queue ! vaapiencode_h264 ! qtmux ! filesink location=/root/capscreen/test2.mp4 enc.

vaapi介绍:https://en.wikipedia.org/wiki/Video_Acceleration_API

硬件编码帧率在framerate=5/1情况下,四核cpu,占用率为30%左右,而软件编码100%左右。而硬件编码在framerate=15/1时cpu占用率为80%,主要是因为videoconvert这一步占去了较多资源。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值