gstreamer常用指令彙總

Gstreamer中一些gst-launch常用命令
用Linux系統中使用gstreamer架構做對媒體開發時,gst-inspect和gst-launch是兩個非常使用的小工具,gst-inspect 在開發時用於查詢庫各個插件element的詳細信息,後者用於在終端快速構建一條pipeline用於播放多媒體。下面列出我在以前的學習和項目開發時常用的gst-launch播放各種多媒體文件的實例:
一、gstreamer實現視頻顯示

gst-launch videotestsrc ! xvimagesink
1
二、gstreamer實現攝像頭採集:
1、可以現實圖像,但圖像卡住不動

gst-launch v4l2src ! xvimagesink
1
2、攝像頭視頻顯示正常

gst-launch v4l2src !video/x-raw-yuv,format=fourccYUY2,width=640,height=480,framerate=15/1 !videorate ! videoscale ! ffmpegcolorspace ! xvimagesink
gst-launch v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=15/1 !queue2 ! videorate ! videoscale ! ffmpegcolorspace ! xvimagesink
1
2
三、攝像頭視頻現實及保存爲avi格式文件

gst-launch -e v4l2src !video/x-raw-yuv,format=fourccYUY2,width=640,height=480,framerate=30/1 ! teename=srctee
srctee. ! queue2 name=squeue ! ffmpegcolorspace ! xvimagesink
srctee. ! queue2 name=fqueue ! videorate ! ffmpegcolorspace !ffenc_mpeg4 ! avimux ! filesink location=test.avi
1
2
3
四、將攝像頭視頻比例設置爲16:9

gst-launch v4l2src ! video/x-raw-yuv,width=640,height=480,framerate=15/1 !aspectratiocrop aspect-ratio=16/9 ! ffmpegcolorspace ! xvimagesink
1
五、保存攝像頭的視頻爲avi格式

gst-launch -e v4l2src ! video/x-raw-yuv, format=fourccYUY2,framerate=30/1, width=640, height=480 ! videorate ! ffmpegcolorspace !ffenc_mpeg4 ! avimux ! filesink location=test.avi
1
六、多個流數據同時錄製

gst-launch -e avimux name=“muxer” ! filesink location=multi.avi
v4l2src ! video/x-raw-yuv, format=fourccYUY2, framerate=25/1,width=640, height=480 ! videorate ! ffmpegcolorspace ! ffenc_mpeg4 ! queue2 !muxer.
pulsesrc ! audioconvert ! audioresample! lamemp3enc target=1 bitrate=64cbr=true ! queue2 ! muxer.
1
2
3
七、畫中畫
1、videomixer可以將兩個或多個視頻流混合到一起:

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.
1
2
2、GstVideoMixerPad能夠改變Z軸和圖像的位置

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=20sink_1::alpha=0.5 sink_1::zorder=3 sink_2::xpos=100 sink_2::ypos=100sink_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.
1
2
3
4
3、GstVideoMixerPad可以制定每個sink

gst-launch
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!
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
1
2
3
4
5
6
八、VideoBox可以用來制定視頻框的大小和位置和apha混合透明度等
1、不透明

gst-launch -e videotestsrc pattern=“snow” ! video/x-raw-yuv,framerate=10/1, width=200, height=150 ! videobox border-alpha=0 top=-100left=-100 !
videomixer name=mix ! ffmpegcolorspace ! xvimagesink videotestsrc !video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix.
1
2
2、指定透明度

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.
1
2
3
3、添加邊框

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 ! xvimagesinkvideotestsrc ! video/x-raw-yuv, framerate=10/1, width=640, height=360 ! mix.
1
2
3
九、VideoWall視頻牆

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.
1
2
3
4
5
6
十、TextOverlay 在視頻上面添加文本,由textoverlay插件實現,可以設置文本的屬性

gst-launch videotestsrc !video/x-raw-yuv,width=640,height=480,framerate=15/1 ! textoverlaytext=“Hello” ! ffmpegcolorspace ! ximagesink
1
十一、TimeOverlay ,由timeoverlay插件實現
1、由timeoverlay插件實現

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=“Streamtime:” shaded-background=true ! xvimagesink
1
2
3
2、cairotimeoverlay

gst-launch videotestsrc ! cairotimeoverlay ! ffmpegcolorspace ! xvimagesink
1
3、clockoverlay時鐘

gst-launch videotestsrc ! cairotimeoverlay ! ffmpegcolorspace ! xvimagesink
gst-launch videotestsrc ! clockoverlay halign=right valign=bottomshaded-background=true time-format="%Y.%m.%D" ! ffmpegcolorspace !ximagesink
1
2
十二、錄製視頻爲ogg格式,帶時間和日期overlay

gst-launch -e v4l2src ! video/x-raw-yuv, format=fourccYUY2,framerate=20/1, width=640, height=480 !
ffmpegcolorspace !
timeoverlay halign=right valign=top ! clockoverlayhalign=left valign=top time-format="%Y/%m/%d %H:%M:%S" !
tee name=“splitter” ! queue2 ! xvimagesinksync=false splitter. !
queue2 ! videorate ! ffmpegcolorspace ! theoraenc bitrate=256! oggmux ! filesink location=webcam.ogg
1
2
3
4
5
十三、視頻牆

gst-launch 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 ! ffmpegcolorspace ! xvimagesink
uridecodebinuri=file:///mnt/hgfs/fedshare/source/video/loveStyle.mp4 ! ffmpegcolorspace !videoscale ! mix.
uridecodebin uri=file:///mnt/hgfs/fedshare/source/video/davincieffect_480p30.mp4! ffmpegcolorspace ! videoscale ! mix.
videotestsrc ! video/x-raw-yuv, framerate=10/1,width=800, height=540 ! mix.
1
2
3
4
十四、播放視頻文件,帶聲音

gst-launch uridecodebinuri=file:///mnt/hgfs/fedshare/source/video/loveStyle.mp4 name=decoder
decoder. ! audioconvert ! autoaudiosink
decoder. ! ffmpegcolorspace ! xvimagesink
1
2
3

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章