gstreamer学习笔记:通过udp传输音视频

一、首先生成一个测试用的avi文件

(1)播放音乐

gst-launch-1.0 filesrc location=/xxx/xxx.wav ! wavparse ! autoaudiosink

(2)将抓取pulseaudio的音频数据和videotestsrc产生的视频数据合成mux.avi多媒体文件

gst-launch-1.0 -e avimux name="mux" ! filesink location=mux.avi videotestsrc pattern=ball ! \
"video/x-raw,framerate=60/1,width=720,height=480" ! videoconvert ! mux. pulsesrc \
device=alsa_output.pci-0000_00_05.0.analog-stereo.monitor ! avenc_aac ! aacparse ! mux.

二、通过udp传输音视频

(1)发送端:

gst-launch -v gstrtpbin name=rtpbin latency=100 uridecodebin uri=file:///xxx/mux.avi name=decoder \
decoder. ! tee name=tee0\
tee0. ! queue2 ! ffmpegcolorspace ! videoscale ! ximagesink \
tee0. ! queue2 ! ffmpegcolorspace ! x264enc ! rtph264pay pt=96 ! queue2 ! rtpbin.send_rtp_sink_0 rtpbin.send_rtp_src_0 !\
queue2 ! udpsink host=xx.xx.xxx.xx port=5000 async=false\
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=xx.xx.xxx.xx port=5003 async=false

流程图如下:


(2)接收端(存储为.avi格式文件)

gst-launch -v gstrtpbin name=rtpbin latency=100 \
udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264,sprop-parameter-sets=(string)\"Z0LAH9kAtD2wEQAAAwABdzWUAA8YMkgA\\,aMuMsg\\=\\=\",ssrc=(uint)2094326868,payload=(int)96,clock-base=(uint)2855623946,seqnum-base=(uint)57709" \
port=5000 ! queue ! rtpbin.recv_rtp_sink_0  rtpbin. ! rtph264depay ! tee name=teevideo teevideo. !  ffdec_h264 ! videoscale ! ffmpegcolorspace ! autovideosink \
teevideo. ! queue ! "video/x-h264,width=720,height=480,framerate=(fraction)25/1" ! ffdec_h264 ! ffmpegcolorspace ! jpegenc ! avimux name=mux mux. ! filesink location="test.avi" \
udpsrc caps="application/x-rtp,media=(string)audio,clock-rate=(int)44100,encoding-name=(string)MP4A-LATM,cpresent=(string)0,config=(string)40002420,ssrc=(uint)277283185,payload=(int)96,clock-base=(uint)3973143737,seqnum-base=(uint)63683" \
port=5003 ! queue ! rtpbin.recv_rtp_sink_1  rtpbin. ! rtpmp4adepay ! tee name=teeaudio teeaudio. ! queue ! faad ! audioconvert ! autoaudiosink \
teeaudio. ! queue ! aacparse ! mux.

流程图如下:


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值