摘要
基于Gstreamer搭建Rtsp Server并不是基于gst-launch方式,而是额外提供了一个工程。工程git地址:git clone git://anongit.freedesktop.org/gstreamer/gst-rtsp-server
这是因为gst-rtsp-server不是以plugin的形式存在,如果您需要基于Gstreamer构建Rtsp Server,则需要同步上述工程,进行本地编译。
工程编译
预先准备:
1、Install gstreamer-1.0 with base/good/ugly/bad plugins
2、Install autoconf automake autopoint libtool and the other missing essential build tools
编译命令:
1、 cd gst-rtsp-server
2、./autogen.sh
3、如果第执行步骤2没出错,则跳过此步骤。如果出错,并类似如下的错误提示,则需进行版本切换。
.......
checking for glib-mkenums... glib-mkenums
checking for GIO... yes
checking for GST... no
configure: Requested 'gstreamer-1.0 >= 1.17.0.1' but version of GStreamer is 1.8.3
configure: error: no gstreamer-1.0 >= 1.17.0.1 (GStreamer) found
版本切换方法:
- 查看所有版本分支:
git branch -av
- 切换到目标版本(笔者是1.8):
git checkout remotes/origin/1.8 -b version1.8
“version1.8”为笔者自定义的分支名称。执行成功后,再次执行git branch -av
查看分支是否切换成功?
然后再次执行步骤2,如果提示缺少什么包,则使用apt-get install安装相应包即可。
遇到缺少包错误及解决办法:
-
错误1
configure: error: You need to have gtk-doc >= 1.12 installed to build
GStreamer RTSP Server Library configure failed解决办法:
sudo apt-get install gtk-doc-tools
-
错误2
configure: No package ‘gstreamer-plugins-base-1.0’ found configure:
error: no gstreamer-plugins-base-1.0 >= 1.8.0 (GStreamer Base Plugins)
found configure failed解决办法:
sudo apt-get install libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev libgstreamer-plugins-bad1.0-dev
4、执行编译命令:make
注:要注意查看有没有提示编译错误信息,根据错误信息进行对症下药(一般是缺其它依赖库)。
效果演示
1、切换到examples目录:cd examples
2、搭建Rtsp Server:./test-launch "( videotestsrc ! x264enc ! rtph264pay name=pay0 pt=96 )"
3、播放rtsp流:gst-launch-1.0 playbin uri=rtsp://127.0.0.1:8554/test
注:笔者的rtsp server 与 client的播放均在同一台PC,因此可以使用127.0.0.1,不同需求可更改IP地址进行适配。