关于GStreamer的一个牛X网页(字符叠加,画中画,屏墙)

本文介绍GStreamer实现字符叠加、画中画、屏墙等功能的方法,包括具体命令行实例,适用于硬盘录像机软件开发。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

分类: 嵌入式

2011-05-02 17:42:06

http://blog.youkuaiyun.com/wzwxiaozheng/archive/2011/01/12/6130818.aspx

在网上闲逛搜GST,不小心发现了一个网址

http://wiki.oz9aec.net/index.php/Gstreamer_cheat_sheet

是WIKI的GStreamer小抄,应该是这样翻译吧。

看了这个网址我就笑了。

上面讲了gstreamer字符叠加,画中画,屏墙等的实现,附带实现的命令,这样实现源码就小case了。

本文描述了gstreamer可实现的功能,主要是针对本硬盘录像机软件功能来说的,以gst-launch命令行的方式,简洁明了,并附有插图。大部分是网络资源,小部分是自己研究。难免有疏漏,敬请指正。

 

参考网址:

1,http://wiki.oz9aec.net/index.php/Gstreamer_cheat_sheet#Video_Wall:_Live_from_Pluto

,gstreamer实现摄像头采集 ,gstreamer实现视频显示 ,将4/3显示转换为16/9 ,实现h264编码并保存 ,将保存的视频播放 ,gstreamer实现视频截图 ,gstreamer实现字符叠加 ,gstreamer实现RTP网络服务端及客户端 ,gstreamer实现画中画 ,gstreamer实现屏墙效果

 

 

1,gstreamer实现摄像头采集:

gst-launch v4l2src ! xvimagesink   gst-launch v4l2src !  video/x-raw-yuv,width=320,height=240,framerate=20/1 ! xvimagesink(未通过)   gst-launch v4l2src ! video/x-raw-yuv,format=\(fourcc\)YUY2,width=320,height=240 ! xvimagesink(通过,)

 

2,gstreamer实现视频显示

gst-launch videotestsrc ! ximagesink (通过) 

 

  

3,gstreamer实现字符叠加

gst-launch videotestsrc ! timeoverlay ! xvimagesink (通过)   gst-launch -v videotestsrc ! video/x-raw-yuv, framerate=25/1, width=640, height=360 ! \   timeoverlay halign=left valign=bottom text="Stream time:" shaded-background=true ! xvimagesink (通过) 添加timeoverlay的效果,timeoverlay基于textoverlay 
  其它一些相关元件的使用: gst-launch videotestsrc ! cairotimeoverlay ! xvimagesink (未通过) gst-launch videotestsrc ! clockoverlay ! xvimagesink (通过) gst-launch videotestsrc ! clockoverlay halign=right valign=bottom shaded-background=true time-format="%Y.%m.%D" ! ffmpegcolorspace ! ximagesink (通过) gst-launch -e v4l2src ! video/x-raw-yuv,format=\(fourcc\)YUY2,width=1280,height=720,framerate=5/1 ! \   ffmpegcolorspace ! \    timeoverlay halign=right valign=top ! clockoverlay halign=left valign=top time-format="%Y/%m/%d %H:%M:%S" ! \    tee name="splitter" ! queue ! xvimagesink sync=false splitter. ! \    queue ! videorate ! video/x-raw-yuv,framerate=1/1 ! \    theoraenc bitrate=256 ! oggmux ! filesink location=webcam.ogg (未通过) 

 

4,gstreamer实现RTP网络服务端及客户端

客户端: gst-launch -v gstrtpbin name=rtpbin latency=100 , udpsrc caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, ssrc=(uint)340005641,clock-base=(uint)2625017333, payload=(int)96,  seqnum-base=(uint)5894" port=5000 ! queue ! rtpbin.recv_rtp_sink_0  rtpbin. ! rtph264depay ! queue ! ffdec_h264 ! videoscale ! autovideosink udpsrc port=5001 ! queue ! rtpbin.recv_rtcp_sink_0 rtpbin.send_rtcp_src_0 ! queue ! udpsink port=5005  sync=true async=false (在windows底下成功,linux应该也没问题)   服务端: gst-launch -v gstrtpbin name=rtpbin latency=100 \         uridecodebin uri=file:///home/miia/test.avi name=decoder \         decoder. ! tee name=tee0 \        tee0. ! queue2 ! ffmpegcolorspace ! videoscale ! autovideosink \        tee0. ! queue2 ! ffmpegcolorspace ! x264enc ! rtph264pay pt=96 ! queue2 ! rtpbin.send_rtp_sink_0 \         rtpbin.send_rtp_src_0 ! queue2 ! udpsink host=192.168.0.105 port=5000  async=false\         rtpbin.send_rtcp_src_0 ! queue2 ! udpsink host=192.168.0.105 port=5001  async=false\         udpsrc port=5005 ! queue2 ! rtpbin.recv_rtcp_sink_0 \          \        decoder. ! tee name=tee1 \         tee1. ! queue2 ! audioconvert ! autoaudiosink \         tee1. ! queue2 !  audioconvert ! faac !     rtpmp4apay pt=96 ! queue2 ! rtpbin.send_rtp_sink_1 \         rtpbin.send_rtp_src_1 ! queue2 ! udpsink host=192.168.0.105 port=5002  async=false\        rtpbin.send_rtcp_src_1 ! queue2 ! udpsink host=192.168.0.105 port=5003 async=false\        udpsrc port=5007 ! queue2 ! rtpbin.recv_rtcp_sink_1 (在linux底下成功) 
From man gst-launch: Network streaming       Stream video using RTP and network elements.       gst-launch v4l2src ! video/x-raw-yuv,width=128,height=96,format='(fourcc)'UYVY ! ffmpegcolorspace ! ffenc_h263      ! video/x-h263 ! rtph263ppay pt=96 ! udpsink host=192.168.1.1 port=5000 sync=false      Use this command on the receiver       gst-launch  udpsrc port=5000 ! application/x-rtp, clock-rate=90000,payload=96 ! rtph263pdepay queue-delay=0 !       ffdec_h263 ! xvimagesink    

 

5,gstreamer实现视频截图

  gst-launch -e v4l2src ! video/x-raw-yuv,format=\(fourcc\)YUY2,width=1280,height=720,framerate=5/1 ! ffmpegcolorspace ! \   timeoverlay halign=right valign=bottom ! clockoverlay halign=left valign=bottom time-format="%Y/%m/%d %H:%M:%S" ! \    videorate ! video/x-raw-rgb,framerate=1/1 ! ffmpegcolorspace ! pngenc snapshot=false ! multifilesink location="frame%05d.png" (未通过) 

 

6,gstreamer实现画中画效果

gst-launch -e videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=200, height=150 ! videomixer name=mix ! \    ffmpegcolorspace ! xvimagesink videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix. (通过,效果跟图片一样) 在一个窗口中同时显示两个视频界面 
  gst-launch videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=200, height=150 ! \    videomixer name=mix sink_1::xpos=20 sink_1::ypos=20 sink_1::alpha=0.5 sink_1::zorder=3 sink_2::xpos=100 sink_2::ypos=100 sink_2::zorder=2 !\    ffmpegcolorspace ! xvimagesink videotestsrc pattern=13 ! video/x-raw-yuv, framerate=10/1, width=200, height=150 ! mix. \    videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix. 设置视频界面的位置和效果,alpha透明效果 
gst-launch \    videomixer name=mix sink_1::xpos=20 sink_1::ypos=20 sink_1::alpha=0.5 sink_1::zorder=3 sink_2::xpos=100 sink_2::ypos=100 sink_2::zorder=2 ! \   ffmpegcolorspace ! xvimagesink \    videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 !  mix.sink_0 \    videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=200, height=150 !  mix.sink_1 \    videotestsrc pattern=13 ! video/x-raw-yuv, framerate=10/1, width=200, height=150 !  mix.sink_2 (通过,效果非常好,跟图片一样) 
gst-launch -e videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=200, height=150 !  videobox border-alpha=0 top=-20 left=-25 ! \    videomixer name=mix ! ffmpegcolorspace ! xvimagesink videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix.   Videobox的使用: 
  gst-launch -e videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=200, height=150 ! \    videobox border-alpha=0  alpha=0.6 top=-20 left=-25 ! videomixer name=mix ! ffmpegcolorspace ! xvimagesink \    videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix. (通过) Videobox和alpha效果 
  gst-launch -e videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=200, height=150 ! \     videobox border-alpha=1.0 top=-2 bottom=-2 left=-2 right=-2 ! videobox border-alpha=0 alpha=0.6 top=-20 left=-25 ! \    videomixer name=mix ! ffmpegcolorspace ! xvimagesink videotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix. (通过,效果略有出入,不透明) border-alpha,加边框的透明效果 
  gst-launch -e videomixer name=mix ! ffmpegcolorspace ! xvimagesink \   videotestsrc pattern=1 ! video/x-raw-yuv, framerate=5/1, width=320, height=180 ! videobox border-alpha=0 top=0 left=0 ! mix. \    videotestsrc pattern=15 ! video/x-raw-yuv, framerate=5/1, width=320, height=180 ! videobox border-alpha=0 top=0 left=-320 ! mix. \    videotestsrc pattern=13 ! video/x-raw-yuv, framerate=5/1, width=320, height=180 ! videobox border-alpha=0 top=-180 left=0 ! mix. \   videotestsrc pattern=0 ! video/x-raw-yuv, framerate=5/1, width=320, height=180 ! videobox border-alpha=0 top=-180 left=-320 ! mix. \    videotestsrc pattern=3 ! video/x-raw-yuv, framerate=5/1, width=640, height=360 ! mix. (通过) 

 

7,gstreamer实现屏墙效果

   gst-launch -e videomixer name=mix ! ffmpegcolorspace ! xvimagesink \   videotestsrc pattern=0 ! video/x-raw-yuv, framerate=1/1, width=350, height=250 ! \     textoverlay font-desc="Sans 24" text="CAM1" valign=top halign=left shaded-background=true ! \      videobox border-alpha=0 top=-200 left=-50 ! mix. \   videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=1/1, width=350, height=250 ! \      textoverlay font-desc="Sans 24" text="CAM2" valign=top halign=left shaded-background=true ! \      videobox border-alpha=0 top=-200 left=-450 ! mix. \   videotestsrc pattern=13 ! video/x-raw-yuv, framerate=1/1, width=350, height=250 ! \     textoverlay font-desc="Sans 24" text="CAM3" valign=top halign=left shaded-background=true ! \      videobox border-alpha=0 top=-200 left=-850 ! mix. \   multifilesrc location="pluto.jpg" caps="image/jpeg,framerate=1/1" ! jpegdec ! \     textoverlay font-desc="Sans 26" text="Live from Pluto" halign=left shaded-background=true auto-resize=false ! \      ffmpegcolorspace ! video/x-raw-yuv,format=\(fourcc\)AYUV ! mix. (修改几个参数后,通过,但效果不好,根据环境不同,所修改的参数不同。在本次试验中,把最后一行的format=\(fourcc\)AYUV去掉,则通过。本来应该显示三个画面,这次经验显示不全,不知道什么原因。不过经调试三个画面都显示了,但是,图片被黑框档掉一块儿,没有示例图片好看) 
  
可执行的命令行:(通过,需多次执行) gst-launch -e videomixer name=mix ! ffmpegcolorspace ! ximagesink \    videotestsrc pattern=0 ! video/x-raw-yuv, framerate=10/1, width=350, height=250 ! \      textoverlay font-desc="Sans 24" text="CAM1" valign=top halign=left shaded-background=true ! \      videobox border-alpha=0 top=-200 left=-850 ! mix. \    videotestsrc pattern="snow" ! video/x-raw-yuv, framerate=10/1, width=350, height=250 ! \      textoverlay font-desc="Sans 24" text="CAM2" valign=top halign=left shaded-background=true ! \      videobox border-alpha=0 top=-200 left=-450 ! mix. \    videotestsrc pattern=13 ! video/x-raw-yuv, framerate=10/1, width=350, height=250 ! \      textoverlay font-desc="Sans 24" text="CAM3" valign=top halign=left shaded-background=true ! \      videobox border-alpha=0 top=-200 left=-50 ! mix. \    multifilesrc location="pluto.jpg" caps="image/jpeg,framerate=10/1" ! jpegdec ! \      textoverlay font-desc="Sans 26" text="Live from Pluto" halign=left shaded-background=true auto-resize=false ! \     ffmpegcolorspace ! video/x-raw-yuv ! mix.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值