搭建nginx视频推流服务器教程

[复制链接]
mghopy 发表于 2018-8-14 16:19:40 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
主要是nginx模块安装:rtmp模块、h264模块、--width-flv模块,--with-mp4模块,其中装h264模块时可能会出现错误,具体的错误内容看下面的说明。
推拉流的测试使用辅助软件:obs推流工具,splay可以播放m3u8网址文件测试拉流,clv可以播放rtmp地址的媒体流。

1、安装依赖包:
#yum -y install gcc glibc glibc-devel make nasm pkgconfig lib-devel openssl-devel expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_64

二、安装Nginx相关模块
1. 模块安装
# wget http://h264.code-shop.com/downlo ... eaming-2.2.7.tar.gz
# tar zxvf nginx_mod_h264_streaming-2.2.7.tar.gz
# git clone git://github.com/arut/nginx-rtmp-module.git
2.编译安装nginx
简化的 ./configure --with-http_ssl_module  --add-module=/root/nginx-rtmp-module/ --with-http_flv_module --with-http_gzip_static_module --with-http_mp4_module
在nginx-1.14.0目录下新建文件:nginx_configure.sh
然后使用gedit 打开进行编辑:

#!/bin/sh echo "configure start ..." ./configure \--prefix=/usr/local/nginx \--sbin-path=/usr/local/nginx/nginx \--conf-path=/usr/local/nginx/nginx.conf \--pid-path=/usr/local/nginx/nginx.pid \--error-log-path=/usr/local/nginx/logs/error.log \--add-module=../nginx_mod_h264_streaming-2.2.7 \--with-pcre=../pcre-8.12 \--with-zlib=../zlib-1.2.8 \--with-http_dav_module \--with-http_flv_module \--with-http_stub_status_module \--without-http_scgi_module \--without-http_uwsgi_module \--without-http_gzip_module \--without-http_ssi_module \--without-http_proxy_module \--without-http_memcached_module \--without-http_empty_gif_module \--without-mail_pop3_module \--without-mail_imap_module \--without-mail_smtp_module \--with-http_ssl_module \--with-openssl=../openssl-1.0.1c \--add-module=../nginx-rtmp-module \--with-cc-opt=-I/opt/ffmpeg/include \--with-ld-opt=`-L/opt/ffmpeg/lib -Wl, -rpath=/opt/ffmpeg/lib` echo "configure end!"


【保存并退出】
# chmod +x nginx_configure.sh
# ./nginx_configure.sh
# make
# make install
备注:
在执行make的时候可能出现错误1:
adding module in ../nginx_mod_h264_streaming-2.2.7
+ ngx_http_h264_streaming_module was configured
adding module in ../nginx-rtmp-module
+ ngx_rtmp_module was configured
checking for OpenSSL library ... not found

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

configure end!
root@ubuntu:/home/song/nginx-t/nginx-1.6.0# make
make: *** No rule to make target `build', needed by `default'.  Stop.

解决方法:
a)可以安装ssl
apt-get install openssl
apt-get install libssl-dev
b)也可以添加
--with-openssl=<path>
在执行make的时候可能出现错误2:
/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: In function ‘ngx_streaming_handler’:

/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c:158: error: ‘ngx_http_request_t’ has no member named ‘zero_in_uri’

make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] Error 1

make[1]: Leaving directory `/root/nginx-0.8.54'

make: *** [build] Error 2

解决方法:
那么将src/ngx_http_streaming_module.c文件中以下代码删除或者是注释掉就可以了:
/* TODO: Win32 */
if (r->zero_in_uri)
{
return NGX_DECLINED;
}

在执行make的时候可能出现错误3:
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c: 在函数‘esds_read’中:
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:377:16: 错误: 变量‘stream_priority’被设定但未被使用 [-Werror=unused-but-set-variable]
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:376:12: 错误: 变量‘stream_id’被设定但未被使用 [-Werror=unused-but-set-variable]
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c: 在函数‘stsd_parse_vide’中:
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:529:22: 错误: 变量‘level_indication’被设定但未被使用 [-Werror=unused-but-set-variable]
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:528:22: 错误: 变量‘profile_compatibility’被设定但未被使用 [-Werror=unused-but-set-variable]
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:527:22: 错误: 变量‘profile_indication’被设定但未被使用 [-Werror=unused-but-set-variable]
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:526:22: 错误: 变量‘configuration_version’被设定但未被使用 [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
make[1]: *** [objs/addon/src/mp4_reader.o] 错误 1

解决方法:
/root/lnmp1.5/include/upgrade_nginx.sh 中打断点,延迟执行安装,然后更改Makefile文件:
# vim /root/lnmp1.5/src/nginx1/14.0/objs/Makefile (修改objs/Makefile文件, 去掉其中的"-Werror"), 然后就能够正常编译了.
然后在make就能过了。


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

专注素材教程免费分享
全国免费QQ热线

1586680266

周一至周日9:00-23:00

反馈建议

1586680266@qq.com 在线QQ咨询

扫描二维码关注我们

Powered by 资源门户网© 2020-2021 bbs.menhuye.com