gstreamer学习笔记:将音视频合成MPEG2-TS流并打包通过rtp传输
一、通过rtpbin插件发送
(1)发送端
gst-launch -v gstrtpbin name=rtpbin latency=100 mpegtsmux name="mux" ! rtpmp2tpay pt=96 ! rtpbin.send_rtp_sink_0 rtpbin.send_rtp_src_0 \
! udpsink host=localhost port=5002 async=false sync=false videotestsrc pattern=ball !x264enc ! mux. \
filesrc audiotestsrc ! ffenc_aac ! aacparse ! mux.
补充:gstreamer1.0版本命令:
gst-launch-1.0 -v rtpbin name=rtpbin latency=100 mpegtsmux name=mux ! rtpmp2tpay pt=96 ! rtpbin.send_rtp_sink_0 rtpbin.send_rtp_src_0
! udpsink host=172.26.178.209 port=5002 async=false videotestsrc pattern=ball ! "video/x-raw,framerate=60/1,width=360,height=240" !
avenc_mpeg2video ! mux. audiotestsrc ! avenc_aac compliance=-2 ! mux.
说明:1.0用x264enc编码器编码,接收端显示不出图像不知道为啥,于是用avenc_mpeg2video代替之。
流程图:
(2)接收端
gst-launch -v gstrtpbin name=rtpbin latency=100 udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)MP2T-ES,\
ssrc=(uint)2461487073,payload=(int)96,clock-base=(uint)1108150669,seqnum-base=(uint)44671" port=5002 ! rtpbin.recv_rtp_sink_0 rtpbin. ! queue2 ! \
rtpmp2tdepay ! mpegtsdemux name=demux demux. ! decodebin2 ! queue2 ! ffmpegcolorspace ! videoscale ! autovideosink sync=false async=false \
demux. ! decodebin2 ! autoaudiosink
补充:gstreamer1.0版命令:
gst-launch-1.0 -v rtpbin name=rtpbin latency=100 udpsrc caps="application/x-rtp, media=(string)video, clock-rate=(int)90000,
encoding-name=(string)MP2T, ssrc=(uint)4280388371, payload=(int)96, timestamp-offset=(uint)696115925, seqnum-offset=(uint)1582"
port=5002 ! queue2 ! rtpbin.recv_rtp_sink_0 rtpbin. ! queue2 ! rtpmp2tdepay ! queue2 ! tsdemux name=demux demux. ! queue2 !
decodebin ! audioconvert ! "audio/x-raw,layout=(string)interleaved,rate=(int)44100,channels=(int)2" ! autoaudiosink demux. !
queue2 ! avdec_mpeg2video ! "video/x-raw,framerate=60/1,width=360,height=240" ! videoconvert ! ximagesink
流程图:
二、通过Rtsp发送
(1)发送端
./rtsp_launch "mpegtsmux name=mux ! rtpmp2tpay name=pay0 pt=96 videotestsrc pattern=ball !
"video/x-raw,framerate=60/1,width=360,height=240" ! avenc_mpeg2video ! mux. audiotestsrc ! avenc_aac compliance=-2 ! mux."
注:rtsp_launch为官方源码编译的工具,源码如下;
/* GStreamer* Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>** This library is free software; you can redistribute it and/or* modify it under the terms of the GNU Library General Public* License as published by the Free Software Foundation; either* version 2 of the License, or (at your option) any later version.** This library is distributed in the hope that it will be useful,* but WITHOUT ANY WARRANTY; without even the implied warranty of* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU* Library General Public License for more details.** You should have received a copy of the GNU Library General Public* License along with this library; if not, write to the* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,* Boston, MA 02110-1301, USA.*/#include <gst/gst.h>#include <gst/rtsp-server/rtsp-server.h>#define DEFAULT_RTSP_PORT "8554"static char *port = (char *) DEFAULT_RTSP_PORT;static GOptionEntry entries[] = {{"port", 'p', 0, G_OPTION_ARG_STRING, &port,"Port to listen on (default: " DEFAULT_RTSP_PORT ")", "PORT"},{NULL}
};int
main (int argc, char *argv[])
{GMainLoop *loop;GstRTSPServer *server;GstRTSPMountPoints *mounts;GstRTSPMediaFactory *factory;GOptionContext *optctx;GError *error = NULL;optctx = g_option_context_new ("<launch line> - Test RTSP Server, Launch\n\n""Example: \"( videotestsrc ! x264enc ! rtph264pay name=pay0 pt=96 )\"");g_option_context_add_main_entries (optctx, entries, NULL);g_option_context_add_group (optctx, gst_init_get_option_group ());if (!g_option_context_parse (optctx, &argc, &argv, &error)) {g_printerr ("Error parsing options: %s\n", error->message);g_option_context_free (optctx);g_clear_error (&error);return -1;}g_option_context_free (optctx);loop = g_main_loop_new (NULL, FALSE);/* create a server instance */server = gst_rtsp_server_new ();g_object_set (server, "service", port, NULL);/* get the mount points for this server, every server has a default object* that be used to map uri mount points to media factories */mounts = gst_rtsp_server_get_mount_points (server);/* make a media factory for a test stream. The default media factory can use* gst-launch syntax to create pipelines.* any launch line works as long as it contains elements named pay%d. Each* element with pay%d names will be a stream */factory = gst_rtsp_media_factory_new ();gst_rtsp_media_factory_set_launch (factory, argv[1]);/* attach the test factory to the /test url */gst_rtsp_mount_points_add_factory (mounts, "/test", factory);/* don't need the ref to the mapper anymore */g_object_unref (mounts);/* attach the server to the default maincontext */gst_rtsp_server_attach (server, NULL);/* start serving */g_print ("stream ready at rtsp://172.26.178.105:%s/test\n", port);g_main_loop_run (loop);return 0;
}//gcc rtsp_launch.c -o rtsp_launch $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)
编译:(需要下载安装gst-rtsp-server-1.xx.tar.xz;路径:https://gstreamer.freedesktop.org/src/gst-rtsp-server/)
gcc rtsp_launch.c -o rtsp_launch $(pkg-config --cflags --libs gstreamer-1.0 gstreamer-rtsp-server-1.0)
(2)接收端:
gst-launch-1.0 -v rtspsrc location=rtsp://172.26.178.105:8554/test ! queue2 ! rtpmp2tdepay ! queue2 ! tsdemux name=demux
demux. ! queue2 ! decodebin ! audioconvert ! "audio/x-raw,layout=(string)interleaved,rate=(int)44100,channels=(int)2" !
autoaudiosink demux. ! queue2 ! avdec_mpeg2video ! "video/x-raw,framerate=60/1,width=360,height=240" ! videoconvert ! ximagesink
以上命令亲测可用,学习Gstreamer中,持续更新。
gstreamer学习笔记:将音视频合成MPEG2-TS流并打包通过rtp传输相关推荐
- HTML5学习笔记之音视频标签
HTML5学习笔记之音视频标签 其他HTML5相关文章 HTML5学习笔记之HTML5基本介绍 HTML5学习笔记之基础标签 HTML5学习笔记之表格标签 HTML5学习笔记之表单标签 HTML5学习 ...
- 音视频基础之复合流解析:TS流格式的讲解
前言: 今天还是搞双十一活动,价格是440(不包括开发板,开发板自己买,这个我多次说了,具体可以看这篇文章:RV1126多路码流功能),周二恢复500,主要是我自己平时要上班,没有时间搞双十一活动,所 ...
- gstreamer学习笔记---编码videoencoder
既上一节的<gstreamer学习笔记-v4l2src>之后,我们这一次,学习gstreamer的编码流程.稍微了解gstreamer的小伙伴都知道,gstreamer具备强大的音视频 ...
- AVFounction学习笔记之--音视频播放.md
AVFounction学习笔记之–音视频播放 AVFounction是用于处理音视频的框架.它位于Core Audio.Core Video.Core Media.Core Animation框架之上 ...
- gstreamer学习笔记---v4l2src
v4l2src element源码位于gst-plugins-good-xxx/sys/v4l2/gstv4l2src.c,v4l2src主要是从v4l2设备获取视频数据的element,基于v4 ...
- 短视频app源码开发,音视频合成的实现
在短视频app源码开发中,音视频数据的处理是关键,尤其是音视频合成处理,只有有声音的短视频内容才更有吸引力,在短视频app源码中如何实现音视频的合成呢? 音频合成 调用方法 //音视频合成func a ...
- Atitit ffmpeg功能表 多媒体处理类库工具 音频视频 1.1.ffmpeg音视频合成 1.2.Atitit 视频音频分离 提取法 1.3.ffmpeg对视频封装和分离 使用ffmpeg对
Atitit ffmpeg功能表 多媒体处理类库工具 音频视频 目录 1.1. ffmpeg音视频合成 1 1.2. Atitit 视频音频分离 提取法 1 1.3. ffmpeg对视频封装和分离 1 ...
- web三维gis引擎cesium的学习笔记(包含视频融合和动态纹理)
文章目录 web三维gis引擎cesium的学习笔记(包含视频融合和动态纹理) Cesium.Viewer 坐标系 位置方向 官方api文档及示例 Entity API Primitives API ...
- 软件合码器-驾考-驾驶员考试-音视频合成-四合一-多路视频合成一路技术开发-音视频合码器
本技术以实际开发实施案例为基础(驾驶员路考系统用的音视频监控合成) 软件合码器-驾考-驾驶员考试-音视频合成-四合一-多路视频合成一路技术开发-音视频合码器 软件效果: 设计流程: 简介 视频合成软件 ...
最新文章
- 从头学起androidlt;AutoCompleteTextView文章提示文本框.十九.gt;
- vn.py 2.0.2 发布,全功能交易程序开发框架
- 使用Newtonsoft.Json.dll(JSON.NET)动态解析JSON、.net 的json的序列化与反序列化(一)...
- BZOJ 3175 最大独立集
- python五十一:动态导入模块,通过字符串导入模块
- hdu2102(bfs)
- win10:JDK12.0.1环境变量配置
- 人的一生能交多少朋友?
- Java中的代理设计模式
- idea,eclipse创建多模块项目
- 针对Hybrid A*论文解析(5)中的方法的一些验证
- 《Objective-C入门经典》——2.1节Objective-C世界中的面向对象程序设计
- OpenGL ES 简单教程
- OpenMV常用函数整理
- acdsee ultimate 2020 特别版 v13.0附安装教程
- 经典育儿书籍推荐目录
- 考研笔记-chyer
- 哈工大计算机学院专业成绩公示,哈工大2009计算机学院录取名单及初试复试成绩排名...
- 如何在官网下载java JDK或JRE的历史版本
- 智汀教你如何用手机远程控制智能门锁
热门文章
- mac SCp上传文件到阿里云服务器centos
- LInux的网络设置之(Bridged)桥接模式
- 通过JAVA编写DOMINO服务器端插件程序
- python dict的get函数
- Julia 在VScode下的操作方式,B站教程Julia中文社区2020夏季会议
- winform pdf转图片.jpg或.png(O2S.Components.PDFRender4NET)
- 销售订单配置项目说明
- windows server 硬盘满了怎么清理?
- 冰羚Planned features.md翻译
- 2021年中国CRM市场规模及市场格局分析:市场规模达156亿元[图]