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框架中使用gst-launch进行流媒体播放的更多相关文章

  1. 海康威视监控设备的Yv12视频在XNA框架中播放

    最近使用海康威视的5寸一体化智能球,查阅些SDK, 在Winform中海康威视能较好的集成,但是对于Yv12编解码和实时视频流的支持未找到较好的SDK介绍. 因为项目需要是用在XNA游戏框架中,本身有 ...

  2. Apache Shiro在web开发安全框架中的应用

    前阶段就hadoop的分享了一些内容,希望对新手入门的朋友有点帮助吧!对于hadoop新手入门的,还是比较推荐大快搜索的DKHadoop发行版,三节点标准版还是值得拥有的(三节点的标准版是可以免费下载 ...

  3. 【视频开发】OpenCV中Mat,图像二维指针和CxImage类的转换

    在做图像处理中,常用的函数接口有OpenCV中的Mat图像类,有时候需要直接用二维指针开辟内存直接存储图像数据,有时候需要用到CxImage类存储图像.本文主要是总结下这三类存储方式之间的图像数据的转 ...

  4. Web API应用架构在Winform混合框架中的应用(4)--利用代码生成工具快速开发整套应用

    前面几篇介绍了Web API的基础信息,以及如何基于混合框架的方式在WInform界面里面整合了Web API的接入方式,虽然我们看似调用过程比较复杂,但是基于整个框架的支持和考虑,我们提供了代码生成 ...

  5. C#开发微信门户及应用(48) - 在微信框架中整合CacheManager 缓存框架

    在我们的很多框架或者项目应用中,缓存在一定程度上可以提高程序的响应速度,以及减轻服务器的承载压力,因此在一些地方我们都考虑引入缓存模块,这篇随笔介绍使用开源缓存框架CacheManager来实现数据的 ...

  6. 从cocos2d-html5中提取出来的,用做前端开发的框架——cc.js

    从cocos2d-html5中提取出来的,用做前端开发的框架——cc.js /************************************************************* ...

  7. ABP VNext框架中Winform终端的开发和客户端授权信息的处理

    在ABP VNext框架中,即使在它提供的所有案例中,都没有涉及到Winform程序的案例介绍,不过微服务解决方案中提供了一个控制台的程序供了解其IDS4的调用和处理,由于我开发过很多Winform项 ...

  8. iOS开发概述UIkit动力学,讲述UIKit的Dynamic特性,UIkit动力学是UIkit框架中模拟真实世界的一些特性。

    转发:http://my.oschina.net/u/1378445/blog/335014 iOS UIKit动力学 Dynamics UIAttachmentBehavior 实现iMessage ...

  9. VP视频结构化框架

    完成多路视频并行接入.解码.多级推理.结构化数据分析.上报.编码推流等过程,插件式/pipe式编程风格,功能上类似英伟达的deepstream和华为的mxvision,但底层核心不依赖复杂难懂的gst ...

随机推荐

  1. 34、使用Python操作MySql数据库和MsSql数据库

    一.数据库的安装和连接 1. PyMySQL的安装 pip install pymysql 2 .python连接数据库 import pymysql db = pymysql.connect(&qu ...

  2. 27、shutil文件操作、xml、subprocess运行子程序模块(了解)

    一.shutil模块(了解):高级的文件.文件夹.压缩包处理模块. import shutil # shutil.copyfileobj(fsrc, fdst[, length]),将文件内容拷贝到另 ...

  3. 15、Python面向对象基础

    和其它编程语言相比,Python 在尽可能不增加新的语法和语义的情况下加入了类机制. Python中的类提供了面向对象编程的所有基本功能:类的继承机制允许多个基类,派生类可以覆盖基类中的任何方法,方法 ...

  4. WHAT IS GAME-BASED LEARNING?

    https://www.growthengineering.co.uk/what-is-game-based-learning/ Gamification and game-based learnin ...

  5. WinDbg常用命令系列---!findstack

    简介 !findstack扩展查找所有包含指定的符号或模块的堆栈.此命令搜索线程调用堆栈中的特定符号,并显示匹配的线程. 使用形式 !findstack Symbol[DisplayLevel] !f ...

  6. k8s实现灰度发布

    灰度发布在实际生产部署中是经常被使用的方式,常规的方法是手动从前端LB(负载均衡)上将后端服务器摘掉,然后,停服务,最后上传代码,完成软连接更新.在使用CI/CD工具时,这个过程变得自动化了,我们只需 ...

  7. while循环 运算符和编码

    昨日回顾 1. 初识python python是一门弱类型的解释型高级编程语言 解释器: CPython 官方提供的默认解释器. c语言实现的 PyPy 把python程序一次性进行编译. IPyth ...

  8. 下拉选择的blur和click事件冲突了

    当写个下拉选择框时我们希望当input失去焦点时,下拉框消失,或者当选择下拉框中的内容的同时将内容填入input并且使下拉框消失. 这时候我们会想到blur和click,单独使用的时候是没有问题的,但 ...

  9. linux高性能服务器编程 (二) --IP协议详解

    第二章 IP协议详解 什么是IP协议:IP 协议是TCP/IP协议族的动力,它为上层提供了无状态.无连接.不可靠的服务. IP 头部信息:头部信息会出现在每一个IP数据报上,便于记录IP通信的源端IP ...

  10. 解决linux环境下nohup: redirecting stderr to stdout问题

    在生产环境下启动Weblogic时,发现原来好好的nohup信息输出到指定文件中的功能,突然出问题了.现象是控制台输出的信息一部分输出到了我指定的文件,另一部分却输出到了nohup.out,而我是不想 ...