一.前提:
1.要连入相关的设备,虚拟机里的Ubuntu可在“移动设备”里查找相关设备,我浅显的觉得这个设备就是摄像头
2.在Linux上安装相关的gstreamer
3.gst-launch1.0和gst-launch0.1相比有所不同,具体区别见
GStreamer 0.10到1.0移植指南
4.注意命令格式
二.命令
1.实现测试视频显示
gst-launch-1.0 videotestsrc ! xvimagesink
gst-launch-1.0 v4l2src ! xvimagesink
gst-launch-1.0 v4l2src ! video/x-raw,format=YUY2,width=640,height=480,framerate=15/1 ! queue2 ! videorate ! videoscale ! videoconvert ! xvimagesink
gst-launch-1.0 v4l2src ! video/x-raw,format=YUY2,width=640,height=480,framerate=15/1 ! videorate ! videoscale ! videoconvert ! xvimagesink
gst-launch-1.0 v4l2src ! video/x-raw,width=640,height=480,framerate=15/1 ! aspectratiocrop aspect-ratio=16/9 ! videoconvert ! xvimagesink
gst-launch-1.0 -e videomixer name=mix ! videoconvert ! xvimagesink videotestsrc pattern=1 ! video/x-raw,framerate=5/1,width=320, height=180 ! videobox border-alpha=0 top=0 left=0 ! mix. videotestsrc pattern=15 ! video/x-raw,framerate=5/1,width=320, height=180 ! videobox border-alpha=0 top=0 left=-320 ! mix. videotestsrc pattern=13 ! video/x-raw,framerate=5/1,width=320, height=180 ! videobox border-alpha=0 top=-180 left=0 ! mix. videotestsrc pattern=0 ! video/x-raw,framerate=5/1,width=320, height=180 ! videobox border-alpha=0 top=-180 left=-320 ! mix. videotestsrc pattern=3 ! video/x-raw,framerate=5/1,width=640, height=360 ! mix.
6. GstVideoMixerPad能够改变Z轴和图像的位置
gst-launch-1.0 videotestsrc pattern="snow" ! video/x-raw,framerate=10/1, width=200, height=150 ! videomixer name=mix sink_1::xpos=20 sink_1::ypos=20sink_1::alpha=0.5 sink_1::zorder=3 sink_2::xpos=100 sink_2::ypos=100sink_2::zorder=2 ! videoconvert ! xvimagesink videotestsrc pattern=13 ! video/x-raw,framerate=10/1, width=200, height=150 ! mix. videotestsrc ! video/x-raw,framerate=10/1, width=640,height=360 ! mix.
gst-launch-1.0 videomixer name=mix sink_1::xpos=20 sink_1::ypos=20sink_1::alpha=0.5 sink_1::zorder=3 sink_2::xpos=100 sink_2::ypos=100 sink_2::zorder=2 ! videoconvert ! xvimagesink videotestsrc ! video/x-raw,framerate=10/1, width=640,height=360 ! mix.sink_0 videotestsrc pattern="snow" ! video/x-raw,framerate=10/1, width=200, height=150 ! mix.sink_1 videotestsrc pattern=13 ! video/x-raw,framerate=10/1,width=200, height=150 ! mix.sink_2
8.VideoBox可以用来制定视频框的大小和位置和apha混合透明度等
第一种 不透明:
第二种 指定透明度
gst-launch-1.0 -e videotestsrc pattern="snow" ! video/x-raw,framerate=10/1, width=200, height=150 ! videobox border-alpha=0 alpha=0.6 top=-20 left=-25 ! videomixer name=mix ! videoconvert ! xvimagesink videotestsrc ! video/x-raw,framerate=10/1, width=640,height=360 ! mix.
gst-launch-1.0 -e videotestsrc pattern="snow" ! video/x-raw,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 ! videoconvert ! xvimagesink videotestsrc ! video/x-raw,framerate=10/1, width=640, height=360 ! mix.
(没看出区别,不知道对不对)
9.timeoverlay插件
gst-launch-1.0 videotestsrc ! timeoverlay ! xvimagesink
gst-launch-1.0 -v videotestsrc ! video/x-raw,framerate=25/1, width=640,height=360 ! timeoverlay halignment=left valignment=bottom text="Streamtime:" shaded-background=true ! xvimagesink
gst-launch-1.0 videotestsrc ! clockoverlay halignment=right valignment=bottom shaded-background=true time-format="%Y.%m.%D" ! videoconvert ! ximagesink
11.录制视频为ogg格式,带时间和日期overlay(覆盖)
gst-launch-1.0 -e v4l2src ! video/x-raw,format=YUY2,framerate=20/1, width=640, height=480 ! videoconvert ! timeoverlay halignment=right valignment=top ! clockoverlay halignment=left valignment=top time-format="%Y/%m/%d %H:%M:%S" ! tee name="splitter" ! queue2 ! xvimagesink sync=false splitter. ! queue2 ! videorate ! videoconvert ! theoraenc bitrate=256 ! oggmux ! filesink location=webcam.ogg
gst-launch-1.0 videomixer name=mix sink_1::xpos=20 sink_1::ypos=20sink_1::alpha=1.0 sink_1::zorder=3 sink_2::xpos=40 sink_2::ypos=40sink_2::zorder=2 ! videoconvert ! xvimagesink uridecodebin uri=file:///home/xrr/视频/a.mp4 ! videoconvert ! videoscale ! mix. uridecodebin uri=file:///home/xrr/视频/b.mp4 ! videoconvert ! videoscale ! mix. videotestsrc ! video/x-raw,framerate=10/1,width=800, height=540 ! mix.
(没有声音,a.mp4在下面)
gst-launch-1.0 uridecodebin uri=file:///home/xrr/视频/b.mp4 name=decoder decoder. ! audioconvert ! autoaudiosink decoder. ! videoconvert ! xvimagesink