gst-rtsp-server编译测试

本文介绍如何在Ubuntu 14.04环境下编译安装GST-RTSP服务器,并详细记录了解决过程中遇到的问题及解决方法。此外,还提供了如何测试GST-RTSP服务器并实现视频流推送的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://blog.csdn.net/zhoudekuai/article/details/8539432
gst-rtsp-server编译测试


分类: 流媒体 Linux c/c++ 2013-01-24 19:28 2550人阅读 评论(1) 收藏 举报
gst-rtsp gstreamer v4l2




最近在做全志A80平台的4K相机(RK3688的八核处理器只能够支持2K相机),调好之后就让全志A80作为4K的RTSP流媒体服务器。




操作系统选择(虚拟机VMware11中安装):
http://old-releases.ubuntu.com/releases/14.04.0/
ubuntu-14.04-desktop-amd64.iso


sudo apt-get install已经安装了freescale的i.MX6Q的android4.2.2/android4.4.2的软件。




1、下载源码包
gst-rtsp-0.10.8.tar.bz2(源地址:http://people.freedesktop.org/~wtay/)
http://people.freedesktop.org/~wtay/gst-rtsp-0.10.8.tar.bz2


libtool-2.4.tar.gz
http://ftpmirror.gnu.org/libtool/libtool-2.4.tar.gz
http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.gz


gtk-doc-1.18.tar.bz2
http://ftp.gnome.org/pub/gnome/sources/gtk-doc/1.18/gtk-doc-1.18.tar.xz
Download (HTTP): http://ftp.gnome.org/pub/gnome/sources/gtk-doc/1.24/gtk-doc-1.24.tar.xz




2、安装libtool和gtk-doc两个软件包
libtool顺利通过。
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/libtool-2.4$ ./configure 
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/libtool-2.4$ make
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/libtool-2.4$ sudo make install
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/libtool-2.4$ libtool --help
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/libtool-2.4$ libtool --version


gtk-doc配置时出错:
checking for DocBook XML DTD V4.3 in XML catalog... found
checking for DocBook XSL Stylesheets in XML catalog... not found
查看地gtk-doc的REAME有说软件的依赖包,可是提供的网址我访问不了。死马当活马医的试了下直接安装xsl竟然成功了。
sudo apt-get install docbook-xsl
再config编译通过。


rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gtk-doc-1.18$ ./configure 
……
config.status: executing libtool commands
configure:
gtk-doc was configured with the following options:
==================================================
configure: ** Python based tools enabled, using /usr/bin/python
configure: ** SGML support enabled, using /usr/bin/openjade
configure: ** XML PDF support enabled, using /usr/bin/dblatex
configure:    Gnome-doc-utils support disabled
configure:    Scrollkeeper support disabled
configure:    Syntax highlighting of examples disabled
configure: ** Building regression tests
configure:    Debug tracing disabled
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gtk-doc-1.18$ sudo apt-get install gnome-doc-utils
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gtk-doc-1.18$ sudo apt-get install scrollkeeper
……
config.status: executing libtool commands
configure:
gtk-doc was configured with the following options:
==================================================
configure: ** Python based tools enabled, using /usr/bin/python
configure: ** SGML support enabled, using /usr/bin/openjade
configure: ** XML PDF support enabled, using /usr/bin/dblatex
configure: ** Gnome-doc-utils support enabled
configure: ** Scrollkeeper support enabled
configure:    Syntax highlighting of examples disabled
configure: ** Building regression tests
configure:    Debug tracing disabled
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gtk-doc-1.18$ 
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gtk-doc-1.18$ make
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gtk-doc-1.18$ sudo make install
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gtk-doc-1.18$ 




3、安装gst-rtsp-0.10.8
解压后运行autogen.sh。


rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8$ 
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8$ ./autogen.sh 
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
ln: failed to create symbolic link ‘.git/hooks/pre-commit’: No such file or directory
+ check for build tools
  checking for autoconf >= 2.60 ... found 2.69, ok.
  checking for automake >= 1.10 ... found 1.14.1, ok.
  checking for autopoint >= 0.17 ... autopoint not found !
You must have autopoint installed to compile gst-rtsp.
Download the appropriate package for your distribution,
or get the source tarball at ftp://ftp.gnu.org/pub/gnu/gettext/
  checking for libtoolize >= 1.5.0 ... found 2.4, ok.
  checking for pkg-config >= 0.8.0 ... found 0.26, ok.


- Please get the right tools before proceeding.
- Alternatively, if you're sure we're wrong, run with --nocheck.
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8$ 
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8$ sudo apt-get install autopoint
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8$  
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8$ ./autogen.sh 
……
checking for GST... no
configure: No package 'gstreamer-0.10' found
configure: error: no gstreamer-0.10 >= 0.10.29 (GStreamer) found
  configure failed
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8$ 
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8$ sudo apt-get install libgstreamer0.10-dev
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8$ sudo apt-get install libgstreamer-plugins-base0.10-dev
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8$ 
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8$ ./autogen.sh 
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8$ make
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8$ sudo make install




rootroot@rootroot-virtual-machine:~/wyb/gst-rtsp-server/gtk-doc-1.18$ sudo apt-get install xsltproc


http://zhidao.baidu.com/link?url=UAWMi6em_Vfn0fBsVb-qOwBYQfmO71OEOpPVTXuq3hZDZmrRCOnfyHR4WirN8ReBIkMLkg0tuuPdwpHsyGg4Bq
sudo apt-get install libgstreamer0.10-dev(之前会报找不到libgstreamer0.10的错误)
sudo apt-get install libgstreamer-plugins-base0.10-dev




安装必须的库:
http://blog.csdn.net/liukang325/article/details/45025853
ubuntu下 gstreamer 的配置及播放音视频例子
sudo apt-get install libgstreamer0.10-dev gstreamer-tools gstreamer0.10-tools gstreamer0.10-doc
sudo apt-get install gstreamer0.10-plugins-base gstreamer0.10-plugins-good gstreamer0.10-plugins-ugly gstreamer0.10-plugins-bad gstreamer0.10-plugins-bad-multiverse


不安装就会报错:
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8/examples$ ./test-readme 


(lt-test-readme:2894): GLib-GObject-CRITICAL **: g_object_ref: assertion 'G_IS_OBJECT (object)' failed


** (lt-test-readme:2894): CRITICAL **: gst_rtsp_media_factory_get_auth: assertion 'GST_IS_RTSP_MEDIA_FACTORY (factory)' failed
GLib (gthread-posix.c): Unexpected error from C library during 'pthread_mutex_lock': Invalid argument.  Aborting.
Aborted (core dumped)
rootroot@rootroot-ThinkPad-X220:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8/examples$ 




http://www.linuxidc.com/Linux/2014-12/111000.htm
在Ubuntu 14.10上安装VLC播放器
sudo apt-get install vlc




4、测试gst-rtsp
首先要看下gst-rtsp安装包中doc目录中的README.这个文档介绍了gst-rtsp的使用。examples目录中有示例程序,已经全部编译好了。
先运行个简单的: 
./test-readme


另开一终端运行:vlc rtsp://localhost:8554/test即可看到图像。九十年代电视台停播时的画面,好有感觉。
到此gst-rtsp-server的编译完成了。


如果是局域网的其他电脑,比如windows电脑,请使用ubuntu的IP地址比如:192.168.11.236。具体请通过ifconfig查询。localhost只能够在本机中执行。
rtsp://192.168.11.236:8554/test




示例程序中有个超好用的类似gst-lanuch的工具。
$ ./test_launch "( videotestsrc is-live=1 ! x264enc ! rtph264pay name=pay0 pt=96 )"
这个命令效果跟.test-readme是一样的。


rootroot@rootroot-virtual-machine:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8/examples$ ./test-launch 
usage: /home/rootroot/wyb/gst-rtsp-server/gst-rtsp-0.10.8/examples/.libs/lt-test-launch <launch line> 
example: /home/rootroot/wyb/gst-rtsp-server/gst-rtsp-0.10.8/examples/.libs/lt-test-launch "( videotestsrc ! x264enc ! rtph264pay name=pay0 pt=96 )"
rootroot@rootroot-virtual-machine:~/wyb/gst-rtsp-server/gst-rtsp-0.10.8/examples$ ./test-launch "( videotestsrc ! x264enc ! rtph264pay name=pay0 pt=96 )"


./test-launch "( videotestsrc is-live=1 ! x264enc ! rtph264pay name=pay0 pt=96 )"




我直接读取摄像头(笔记本电脑一般自带摄像头,台式机请插入USB摄像头)视频的命令就是它了:
$ ./test-launch "( v4l2src ! video/x-raw-yuv,format='fourcc'YUY2,width=640,height=480 ! ffmpegcolorspace ! x264enc ! rtph264pay name=pay0 pt=96 )"
用vlc打开vlc rtsp://localhost:8554/test成功看到图像。
rtsp://192.168.11.236:8554/test




另,gst-rtsp是多播放支持的。不过示例程序test-readme和test_launch经过测试都只支持单播!




下载地址:
http://download.csdn.net/detail/wb4916/9242663

gst-rtsp-server编译测试20151105 0949  




### 如何在 Linux 上安装配置 gst-rtsp-server #### 下载 gst-rtsp-server 镜像源 gst-rtsp-server 是基于 GStreamer 构建的 RTSP 流媒体服务器模块。对于 1.18 及更高版本,由于某些依赖关系可能无法直接编译成功[^1]。因此,在实际操作中可以选择稳定版本进行安装。 推荐使用的版本为 `gst-rtsp-server` 的 1.14.4 版本,其原始 tarball 文件名为 `gst-rtsp-server1.0_1.14.4.orig.tar.xz`。可以通过以下命令下载该文件: ```bash wget http://ftp.debian.org/debian/pool/main/g/gst-rtsp-server1.0/gst-rtsp-server1.0_1.14.4.orig.tar.xz ``` 如果需要更新到最新版本,则可以访问官方仓库获取最新的代码库[^2]: ```bash git clone https://gitcode.com/gh_mirrors/gs/gst-rtsp-server.git cd gst-rtsp-server ``` #### 编译并安装 gst-rtsp-server 为了确保 gst-rtsp-server 能够正常运行,需先确认已安装必要的开发工具和依赖项。以下是具体步骤说明: ##### 安装基础依赖环境 GStreamer 和相关插件是 gst-rtsp-server 运行的基础组件。通过以下命令安装所需依赖项: ```bash sudo apt update && sudo apt install -y build-essential libgstreamer1.0-dev \ libgstreamer-plugins-base1.0-dev gstreamer1.0-tools gstreamer1.0-x \ gstreamer1.0-alsa gstreamer1.0-pulseaudio gstreamer1.0-libav \ gstreamer1.0-gl gstreamer1.0-gtk3 pkg-config ``` ##### 解压与构建软件包 解压缩之前下载的 `.tar.xz` 压缩包,并进入对应的目录完成编译过程: ```bash tar xf gst-rtsp-server1.0_1.14.4.orig.tar.xz cd gst-rtsp-server1.0-1.14.4/ mkdir build && cd build meson .. --prefix=/usr/local ninja sudo ninja install ``` 上述过程中使用 Meson 构建系统替代传统的 Autotools 工具链来简化跨平台支持。 #### 启动 gst-rtsp-server 实例 完成安装之后即可尝试启动一个简单的 RTSP Server 来验证功能是否正常工作。下面是一个基本的例子程序脚本: ```c #include <gst/gst.h> #include <gst/rtsp-server/rtsp-server.h> int main(int argc, char *argv[]) { GstRTSPServer *server; GstRTSPMountPoints *mounts; GstRTSPMediaFactory *factory; gst_init(&argc, &argv); /* 创建一个新的 RTSP 服务端 */ server = gst_rtsp_server_new(); mounts = gst_rtsp_server_get_mount_points(server); factory = gst_rtsp_media_factory_new(); gst_rtsp_media_factory_set_launch(factory, "( videotestsrc ! videoconvert ! x264enc ! rtph264pay name=pay0 pt=96 )"); gst_rtsp_mount_points_add_factory(mounts, "/test", factory); g_object_unref(mounts); /* 设置监听地址,默认绑定至 localhost:8554 */ gst_rtsp_server_attach(server, NULL); g_print("Stream ready at rtsp://localhost:8554/test\n"); g_main_loop_run(g_main_loop_new(NULL, FALSE)); return 0; } ``` 保存以上 C 源码为 `main.c` 并执行如下指令将其编译成可执行二进制文件: ```bash gcc $(pkg-config --cflags --libs gstreamer-rtsp-server-1.0) -o test-rtsp main.c ./test-rtsp ``` 此时应该可以在本地机器上看到一条消息提示流已经准备好供客户端连接访问。 ---
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值