Chinaunix首页 | 论坛 | 博客
  • 博客访问: 180075
  • 博文数量: 40
  • 博客积分: 2036
  • 博客等级: 大尉
  • 技术积分: 430
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-12 22:39
文章分类

全部博文(40)

文章存档

2013年(3)

2012年(1)

2011年(18)

2010年(18)

分类:

2010-07-10 10:11:02

又捣鼓了一天,终于算是可以了,在服务器端视频、声音都能播放,并保存到文件中。
本来想是用vorbis的音频流,但是一直没成功,在gstreaer-devel上发贴也没人回,。。。
所以没办法音频用了AAC,也就是Audio/MPEG4。
还有就是服务器端的音频流从rtp包中解出来后不能直接mux到文件中,没办法就自己先decode,再code,最后再mux就可以了。真是个笨办法,我想应该有好的方法,但是没找到,在gstreamer-devel里翻也没找到好的方法。希望等以后研究的深入了再说吧!先这样用着。
先把代码贴出来
client:
  gst-launch -v  gstrtpbin name=rtpbin latency=100 \
        uridecodebin uri=file:///home/xingmin/qianyuqianxun.rmvb 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=211.64.20.87 port=5000  async=false\
        rtpbin.send_rtcp_src_0 ! queue2 ! udpsink host=211.64.20.87 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=211.64.20.87 port=5002  async=false\
        rtpbin.send_rtcp_src_1 ! queue2 ! udpsink host=211.64.20.87 port=5003 async=false\
        udpsrc port=5007 ! queue2 ! rtpbin.recv_rtcp_sink_1

server:
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 ! tee name=teevideo teevideo. ! 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 \
teevideo. ! queue ! "video/x-h264,width=800,height=452,framerate=(fraction)25/1" ! matroskamux name=mux mux. ! filesink location="test.mkv" \
        \
    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)4204015526, payload=(int)96, clock-base=(uint)4274968681, seqnum-base=(uint)44386" \
       port=5002 ! queue ! rtpbin.recv_rtp_sink_1  rtpbin. ! rtpmp4adepay ! tee name=teeaudio teeaudio. ! queue ! faad ! audioconvert ! autoaudiosink \
    teeaudio. ! queue ! faad ! audioconvert ! faac ! mux. \
    udpsrc port=5003 ! queue ! rtpbin.recv_rtcp_sink_1   \
    rtpbin.send_rtcp_src_1 ! queue ! udpsink port=5007  sync=true async=false
红色下划线的地方是对于每一个视频每次播放都不一样的,这需要在客户端运行时,把caps copy过来,或是通过其他的方法传过来。
最后,GStreamer在国内感觉用的人很少,或是不少但是没人拿出来分享。用libvlc的人倒是不少。不过,我还是感觉GStreamer很好,它的插件/管道 等的思想很好,正符合视频/音频流的方式。还有,由于我是做图像处理/模式识别的,它的plugin很好,如果我想实现什么算法,自己实现一个plugin就好了,并且还能达到复用,以后要更加深入的研究,学着写plugin.
That's all for this blog. Thx.

阅读(9913) | 评论(1) | 转发(1) |
给主人留下些什么吧!~~

tianchunlong2016-09-04 19:08:50

你好,我刚开始接触,想问下您,怎么从发送端去获取caps,来更新服务器端的caps。谢谢!