【视频开发】Gstreamer框架中使用gst-launch进行流媒体播放
2017-08-28 19:15
579 查看
Gstreamer框架中使用gst-launch进行流媒体播放
Gstreamer是一套开源的流媒体框架,用其也可以进行流媒体开发,Gstreamer是基于glib库编写的,需要将多个不同功能的元件(element)装进一个箱柜(bin)中,在进行程序编写前,我们可以使用Gstreamer提供的一个小工具gst-launch在终端中在验证我们的想法,验证我们选择的元件和配置的管道是否正确,如果验证正确,编码对于各位小伙伴们就是小case啦!
不用废话了,直接进入我们的主题,一下列出了我以前学习使用Gstreamer进行流媒体开发过程中的一些实例,都是使用gst-launch实现的。
一、RDP协议实现mp3播放
1、服务端
gst-launch filesrc location=/mnt/hgfs/fedshare/source/audio/test.mp3 ! mad! audioconvert \
! audio/x-raw-int,channels=1,depth=16,width=16, rate=44100 !rtpL16pay ! udpsink host=127.0.0.1 port=5000
2、接收端
gst-launch udpsrc port=5000 ! "application/x-rtp,media=(string)audio,clock-rate=(int)44100, width=16, height=16, \
encoding-name=(string)L16, encoding-params=(string)1, channels=(int)1,channel-positions=(int)1, payload=(int)96" ! gstrtpjitterbufferdo-lost=true ! rtpL16depay ! audioconvert ! alsasink sync=false
二、摄像头远程监控
1、发送端
gst-launch -v gstrtpbin name=rtpbin v4l2src device=/dev/video0 ! videorate! videoscale ! ffmpegcolorspace ! 'video/x-raw-yuv, width=(int)320,height=(int)240, framerate=(fraction)15/1' ! \ rtpvrawpay !rtpbin.send_rtp_sink_0 rtpbin.send_rtp_src_0 ! multiudpsinkclients="127.0.0.1:9996"
rtpbin.send_rtcp_src_0 ! multiudpsinkclients="127.0.0.1:9997" sync=false async=false udpsrc port=10000 !rtpbin.recv_rtcp_sink_0
2、接收端
gst-launch udpsrc caps=" application/x-rtp,media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW,sampling=(string)YCbCr-4:2:0, depth=(string)8, width=(string)320,height=(string)240, colorimetry=(string)SMPTE240M, ssrc=(guint)4294234526,payload=(int)96,
clock-base=(guint)520513122, seqnum-base=(guint)28177"port=9996 ! queue ! rtpvrawdepay ! queue ! tee name="splitter"! queue ! ffmpegcolorspace ! autovideosink splitter. ! queue ! ffmpegcolorspace! jpegenc ! avimux ! filesink location=osug-udp-2.avi
三、音频流媒体传输(
1、发送端
gst-launch -v gstrtpbin name=rtpbin latency=100 \
uridecodebin uri=file:///mnt/hgfs/fedshare/source/audio/test.mp3name=decoder \
decoder. ! tee name=tee0 \
tee0. ! queue2 ! audioconvert ! ffenc_aac ! rtpmp4apay pt=96 ! queue2 !rtpbin.send_rtp_sink_1 rtpbin.send_rtp_src_1 ! queue2 ! udpsink host=127.0.0.1port=5002 async=false
2、接收端
gst-launch -v gstrtpbin name=rtpbin latency=100 \
udpsrccaps="application/x-rtp,media=(string)audio,clock-rate=(int)44100,encoding-name=(string)MP4A-LATM,cpresent=(string)0,config=(string)40002420,ssrc=(uint)4204015526,payload=(int)96,clock-base=(uint)4274968681,seqnum-base=(uint)44368"\
port=5002 ! queue2 ! rtpbin.recv_rtp_sink_1 rtpbin. ! rtpmp4adepay ! teename=teeaudio \
teeaudio. ! queue2 ! ffdec_aac ! audioconvert ! autoaudiosink
四、视频文件只传输音频流
1、发送端
gst-launch -v gstrtpbin name=rtpbin latency=100 \
uridecodebin uri=file:///mnt/hgfs/fedshare/source/video/loveStyle.mp4name=decoder \
decoder. ! tee name=tee0 \
tee0. ! queue2 ! ffmpegcolorspace ! x264enc ! rtph264pay pt=96 ! queue2 !rtpbin.send_rtp_sink_0 rtpbin.send_rtp_src_0 ! queue2 ! udpsink host=127.0.0.1port=5000 async=false \
rtpbin.send_rtcp_src_0 ! queue2 ! udpsink host=127.0.0.1 port=5001async=false \
udpsrc port=5005 ! queue2 ! rtpbin.recv_rtcp_sink_0
2、接收端
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,payload=(int)96,clock-base=(uint)2625017333,seqnum-base=(uint)5894"port=5000 \
! queue ! rtpbin.recv_rtp_sink_0 rtpbin. ! rtph264depay ! teename=teevideo \
teevideo. ! queue ! ffdec_h264 ! videoscale ! ffmpegcolorspace !xvimagesink \
udpsrc port=5001 ! queue ! rtpbin.recv_rtcp_sink_0 rtpbin.send_rtcp_src_0! queue ! udpsink host=127.0.0.1 port=5005 sync=true async=false
五、音视频混合流媒体
1、发送端
gst-launch -v gstrtpbin name=rtpbin latency=100 \
uridecodebin uri=file:///mnt/hgfs/fedshare/source/video/loveStyle.mp4name=decoder \
decoder. ! tee name=tee0 \
tee0. ! queue2 ! ffmpegcolorspace ! x264enc ! rtph264pay pt=96 ! queue2 !rtpbin.send_rtp_sink_0 rtpbin.send_rtp_src_0 ! queue2 ! udpsink host=127.0.0.1port=5000 async=false \
rtpbin.send_rtcp_src_0 ! queue2 ! udpsink host=127.0.0.1 port=5001async=false \
udpsrc port=5005 ! queue2 ! rtpbin.recv_rtcp_sink_0 \
decoder. ! tee name=tee1 \
tee1. ! queue2 ! audioconvert ! ffenc_aac ! rtpmp4apay pt=96 ! queue2 !rtpbin.send_rtp_sink_1 rtpbin.send_rtp_src_1 ! queue2 ! udpsink host=127.0.0.1port=5002 async=false \
rtpbin.send_rtcp_src_1 ! queue2 ! udpsink host=127.0.0.1 port=5003async=false \
udpsrc port=5006 ! queue2 ! rtpbin.recv_rtcp_sink_1
2、接收端
gst-launch -v gstrtpbin name=rtpbin latency=100 \
udpsrccaps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264,ssrc=(uint)340005641,payload=(int)96,clock-base=(uint)2625017333,seqnum-base=(uint)5894"port=5000 \
! queue2 ! rtpbin.recv_rtp_sink_0 rtpbin. ! rtph264depay ! teename=teevideo \
teevideo. ! queue2 ! ffdec_h264 ! videoscale ! ffmpegcolorspace ! xvimagesink\
udpsrc port=5001 ! queue2 ! rtpbin.recv_rtcp_sink_0 rtpbin.send_rtcp_src_0! queue2 ! udpsink host=127.0.0.1 port=5005 sync=true async=false \
udpsrccaps="application/x-rtp,media=(string)audio,clock-rate=(int)44100,encoding-name=(string)MP4A-LATM,cpresent=(string)0,config=(string)40002420,ssrc=(uint)4204015526,payload=(int)96,clock-base=(uint)4274968681,seqnum-base=(uint)44386"port=5002 ! queue2 !
rtpbin.recv_rtp_sink_1 rtpbin. ! rtpmp4adepay ! teename=teeaudio \
teeaudio. ! queue2 ! ffdec_aac ! audioconvert ! autoaudiosink \
udpsrc port=5003 ! queue2 ! rtpbin.recv_rtcp_sink_1 rtpbin.send_rtcp_src_1! queue2 ! udpsink host=127.0.0.1 port=5006 sync=true async=false
Gstreamer是一套开源的流媒体框架,用其也可以进行流媒体开发,Gstreamer是基于glib库编写的,需要将多个不同功能的元件(element)装进一个箱柜(bin)中,在进行程序编写前,我们可以使用Gstreamer提供的一个小工具gst-launch在终端中在验证我们的想法,验证我们选择的元件和配置的管道是否正确,如果验证正确,编码对于各位小伙伴们就是小case啦!
不用废话了,直接进入我们的主题,一下列出了我以前学习使用Gstreamer进行流媒体开发过程中的一些实例,都是使用gst-launch实现的。
一、RDP协议实现mp3播放
1、服务端
gst-launch filesrc location=/mnt/hgfs/fedshare/source/audio/test.mp3 ! mad! audioconvert \
! audio/x-raw-int,channels=1,depth=16,width=16, rate=44100 !rtpL16pay ! udpsink host=127.0.0.1 port=5000
2、接收端
gst-launch udpsrc port=5000 ! "application/x-rtp,media=(string)audio,clock-rate=(int)44100, width=16, height=16, \
encoding-name=(string)L16, encoding-params=(string)1, channels=(int)1,channel-positions=(int)1, payload=(int)96" ! gstrtpjitterbufferdo-lost=true ! rtpL16depay ! audioconvert ! alsasink sync=false
二、摄像头远程监控
1、发送端
gst-launch -v gstrtpbin name=rtpbin v4l2src device=/dev/video0 ! videorate! videoscale ! ffmpegcolorspace ! 'video/x-raw-yuv, width=(int)320,height=(int)240, framerate=(fraction)15/1' ! \ rtpvrawpay !rtpbin.send_rtp_sink_0 rtpbin.send_rtp_src_0 ! multiudpsinkclients="127.0.0.1:9996"
rtpbin.send_rtcp_src_0 ! multiudpsinkclients="127.0.0.1:9997" sync=false async=false udpsrc port=10000 !rtpbin.recv_rtcp_sink_0
2、接收端
gst-launch udpsrc caps=" application/x-rtp,media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW,sampling=(string)YCbCr-4:2:0, depth=(string)8, width=(string)320,height=(string)240, colorimetry=(string)SMPTE240M, ssrc=(guint)4294234526,payload=(int)96,
clock-base=(guint)520513122, seqnum-base=(guint)28177"port=9996 ! queue ! rtpvrawdepay ! queue ! tee name="splitter"! queue ! ffmpegcolorspace ! autovideosink splitter. ! queue ! ffmpegcolorspace! jpegenc ! avimux ! filesink location=osug-udp-2.avi
三、音频流媒体传输(
1、发送端
gst-launch -v gstrtpbin name=rtpbin latency=100 \
uridecodebin uri=file:///mnt/hgfs/fedshare/source/audio/test.mp3name=decoder \
decoder. ! tee name=tee0 \
tee0. ! queue2 ! audioconvert ! ffenc_aac ! rtpmp4apay pt=96 ! queue2 !rtpbin.send_rtp_sink_1 rtpbin.send_rtp_src_1 ! queue2 ! udpsink host=127.0.0.1port=5002 async=false
2、接收端
gst-launch -v gstrtpbin name=rtpbin latency=100 \
udpsrccaps="application/x-rtp,media=(string)audio,clock-rate=(int)44100,encoding-name=(string)MP4A-LATM,cpresent=(string)0,config=(string)40002420,ssrc=(uint)4204015526,payload=(int)96,clock-base=(uint)4274968681,seqnum-base=(uint)44368"\
port=5002 ! queue2 ! rtpbin.recv_rtp_sink_1 rtpbin. ! rtpmp4adepay ! teename=teeaudio \
teeaudio. ! queue2 ! ffdec_aac ! audioconvert ! autoaudiosink
四、视频文件只传输音频流
1、发送端
gst-launch -v gstrtpbin name=rtpbin latency=100 \
uridecodebin uri=file:///mnt/hgfs/fedshare/source/video/loveStyle.mp4name=decoder \
decoder. ! tee name=tee0 \
tee0. ! queue2 ! ffmpegcolorspace ! x264enc ! rtph264pay pt=96 ! queue2 !rtpbin.send_rtp_sink_0 rtpbin.send_rtp_src_0 ! queue2 ! udpsink host=127.0.0.1port=5000 async=false \
rtpbin.send_rtcp_src_0 ! queue2 ! udpsink host=127.0.0.1 port=5001async=false \
udpsrc port=5005 ! queue2 ! rtpbin.recv_rtcp_sink_0
2、接收端
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,payload=(int)96,clock-base=(uint)2625017333,seqnum-base=(uint)5894"port=5000 \
! queue ! rtpbin.recv_rtp_sink_0 rtpbin. ! rtph264depay ! teename=teevideo \
teevideo. ! queue ! ffdec_h264 ! videoscale ! ffmpegcolorspace !xvimagesink \
udpsrc port=5001 ! queue ! rtpbin.recv_rtcp_sink_0 rtpbin.send_rtcp_src_0! queue ! udpsink host=127.0.0.1 port=5005 sync=true async=false
五、音视频混合流媒体
1、发送端
gst-launch -v gstrtpbin name=rtpbin latency=100 \
uridecodebin uri=file:///mnt/hgfs/fedshare/source/video/loveStyle.mp4name=decoder \
decoder. ! tee name=tee0 \
tee0. ! queue2 ! ffmpegcolorspace ! x264enc ! rtph264pay pt=96 ! queue2 !rtpbin.send_rtp_sink_0 rtpbin.send_rtp_src_0 ! queue2 ! udpsink host=127.0.0.1port=5000 async=false \
rtpbin.send_rtcp_src_0 ! queue2 ! udpsink host=127.0.0.1 port=5001async=false \
udpsrc port=5005 ! queue2 ! rtpbin.recv_rtcp_sink_0 \
decoder. ! tee name=tee1 \
tee1. ! queue2 ! audioconvert ! ffenc_aac ! rtpmp4apay pt=96 ! queue2 !rtpbin.send_rtp_sink_1 rtpbin.send_rtp_src_1 ! queue2 ! udpsink host=127.0.0.1port=5002 async=false \
rtpbin.send_rtcp_src_1 ! queue2 ! udpsink host=127.0.0.1 port=5003async=false \
udpsrc port=5006 ! queue2 ! rtpbin.recv_rtcp_sink_1
2、接收端
gst-launch -v gstrtpbin name=rtpbin latency=100 \
udpsrccaps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264,ssrc=(uint)340005641,payload=(int)96,clock-base=(uint)2625017333,seqnum-base=(uint)5894"port=5000 \
! queue2 ! rtpbin.recv_rtp_sink_0 rtpbin. ! rtph264depay ! teename=teevideo \
teevideo. ! queue2 ! ffdec_h264 ! videoscale ! ffmpegcolorspace ! xvimagesink\
udpsrc port=5001 ! queue2 ! rtpbin.recv_rtcp_sink_0 rtpbin.send_rtcp_src_0! queue2 ! udpsink host=127.0.0.1 port=5005 sync=true async=false \
udpsrccaps="application/x-rtp,media=(string)audio,clock-rate=(int)44100,encoding-name=(string)MP4A-LATM,cpresent=(string)0,config=(string)40002420,ssrc=(uint)4204015526,payload=(int)96,clock-base=(uint)4274968681,seqnum-base=(uint)44386"port=5002 ! queue2 !
rtpbin.recv_rtp_sink_1 rtpbin. ! rtpmp4adepay ! teename=teeaudio \
teeaudio. ! queue2 ! ffdec_aac ! audioconvert ! autoaudiosink \
udpsrc port=5003 ! queue2 ! rtpbin.recv_rtcp_sink_1 rtpbin.send_rtcp_src_1! queue2 ! udpsink host=127.0.0.1 port=5006 sync=true async=false
相关文章推荐
- Gstreamer框架中使用gst-launch进行流媒体播放
- Gstreamer框架中使用gst-launch进行流媒体播放
- Gstreamer框架中使用gst-launch进行流媒体播放
- Gstreamer框架中使用gst-launch进行流媒体播放
- 使用 Kotlin 读取本地视频并使用Vitamio框架编写万能播放器进行播放(一)
- 【视频开发】Gstreamer中一些gst-launch常用命令
- 使用 Kotlin 读取本地视频并使用Vitamio框架编写万能播放器进行播放(二)
- 使用QT4和OSSBuild的gstreamer库开发视频播放程序
- android开发视频播放器-----视频播放 Vitamio框架的使用(一)
- 【iOS开发-97】MediaPlayer框架中MPMoviePlayerController类视频播放的使用,运行时runtime
- 使用Play框架快速进行Java Web应用开发 出处:IT专家网
- 高效率视频播放: 如何使用3D API 进行视频的高质量回放(1)
- 【Cocos2d游戏开发之十四】音频/音效/视频播放(利用Cocos2D-iPhone-Extensions嵌入Cocos2d进行视频播放!)
- ios 编程: ipad 和 iphone开发中使用 UIWebView 来播放视频的时候,在页面切换时 停止播放
- 图解使用Win8Api进行Metro风格的程序开发十----音乐播放
- gstreamer 使用命令来播放视频
- android游戏开发框架libgdx的使用(二十二)—利用TABLELAYOUT进行布局
- 一步一步教你使用AgileEAS.NET基础类库进行应用开发-WinForm应用篇-复杂业务的实现(商品入库)-附案例操作视频
- 使用框架进行开发的一点理解
- 高效率视频播放: 如何使用3D API 进行视频的高质量回放(1)