Centos7 搭建Nginx+rtmp+hls直播推流服务器
1 准备工具
使用yum安装git
[root~]# yum -y install git
下载nginx-rtmp-module,官方github地址
// 通过git clone 的方式下载到服务器上
[root~]# git clone https://github.com/arut/nginx-rtmp-module.git
yum 安装 openssl
[root~]# yum -y install openssl openssl-devel
2 安装Nginx服务器,官方网址
下载Nginx解压,并添加rtmp和openssl支持
如果需要nginx监控模块 下面倒数第二行后面添加
--with-http_stub_status_module
//这里我安装的是 nginx-1.10.3 版本
[root~]# wget http://nginx.org/download/nginx-1.10.3.tar.gz
[root~]# tar -zxvf nginx-1.10.3.tar.gz
[root~]# cd nginx-1.10.3
//添加rtmp和openssl支持
[root~]# ./configure --add-module=/替换为自己的安装路径(path/to)/nginx-rtmp-module --with-http_ssl_module
[root~]# make && make install
如果已经安装过Nginx,只需要找到Nginx源码目录添加rtmp的支持即可
1.查看当前安装的Nginx版本
[root~]# /usr/local/nginx/sbin/nginx -v
查询结果:nginx version: nginx/1.10.3
2.再使用find命令查找其位置
[root~]# find / -name nginx-1.10.3
查询结果:/root/nginx-1.10.3
3.cd到查询到的源目录
[root~]# cd /root/nginx-1.10.3
4.添加rtmp的支持(如果看到一个绿色的 configure 文件就说明查找对了)
[root~]# ./configure --add-module=/替换为自己的安装路径(path/to)/nginx-rtmp-module
[root~]# make && make install
5.启动nignx
[root~]# /usr/local/nginx/sbin/nginx
3 修改Nginx配置文件nginx.conf
使用vi命令打开 nginx.conf,输入 i 进入编辑状态
[root~]# vi /usr/local/nginx/conf/nginx.conf
# 在http节点同级加上rtmp配置:
rtmp {
server {
listen 1935;
chunk_size 2048;
drop_idle_publisher 10s; #指定的时间内丢弃空闲的publisher application rtmplive {
live on;
record off; notify_method get; # 跳转的时候,默认以POST方式传输参数,修改成GET方式(权限验证url参数方式用)
on_publish http://127.0.0.1/on_publish; # 推流权限验证地址(可选)
#转推流
push rtmp://****;
}
}
}
# HLS 配置(可选)
application hls {
live on;
hls on;
hls_path /tmp/hls; #需要手动创建路径
hls_continuous on; #切片编号从上一次结束开始
}
}
}
#http配置 简单权限验证 HLS配置
http {
server {
listen 8080;
# 推流权限验证
location /on_publish {
default_type text/html;
if ( $args ~ pass=1234 ) { # 如果url参数包括 pass=1234
return 200;
}
return 404;
}
# This URL provides RTMP statistics in XML
location /stat {
rtmp_stat all;
# Use this stylesheet to view XML as web page
# in browser
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
# XML stylesheet to view RTMP stats.
# Copy stat.xsl wherever you want
# and put the full directory path here
root /path/to/stat.xsl/;
}
# HLS(可选)
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp; #root path
add_header Cache-Control no-cache;
}
}
}
nginx状态监控页面(需前面安装http_stub_status_module)
# nginx状态监控页面
location /status {
# Turn on nginx stats
stub_status on;
# I do not need logs for stats
access_log off;
# Security: Only allow access from 192.168.1.100 IP #
#allow 192.168.1.100;
# Send rest of the world to /dev/null #
#deny all
}
重启nginx
[root~]# nginx -s reload
开机启动
# vi /lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target [Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx reload
ExecStop=/usr/local/nginx/sbin/nginx quit
PrivateTmp=true [Install]
WantedBy=multi-user.target
# systemctl enable nginx.service
systemctl start nginx.service 启动nginx
systemctl stop nginx.service 结束nginx
systemctl restart nginx.service 重启nginx
4 推流
使用obs推流
url填写 rtmp://[服务器ip]:[端口]/[nginx配置中rtmp的application名称],如 rtmp://10.129.0.100:1935/hls
如配置HLS,需填写串流码,名称随意,如 demo,这个名称在HLS方式拉流时会用到
如配置url验证,在url后面添加验证参数,如 rtmp://10.129.0.100:1935/hls?pass=1234,“?pass=1234”可以放在串码流中

5 拉流
使用vlc拉流
填写网络URL 如 http://10.129.0.100:8080/hls/demo.m3u8
注意m3u8的文件名与推流时填的串流码一致
或者填写rtmp链接,如 rtmp://10.129.0.100:1935/hls

附:
nginx默认路径:/usr/local/nginx/html
centos7 搭建rtmp+hls直播流服务器及rtmp转hls直播流(nginx+nginx-rtmp-module-master+obs)
nginx nginx-rtmp-module 基于rtmp协议实现公网推流拉流
【官方文档】Nginx模块Nginx-Rtmp-Module学习笔记(二)HLS 指令详解
「自己开发直播」实现nginx-rtmp-module多频道输入输出与权限控制
Centos7 搭建Nginx+rtmp+hls直播推流服务器的更多相关文章
- 三、直播整体流程 五、搭建Nginx+Rtmp直播流服务
HTML5实现视频直播功能思路详解_html5教程技巧_脚本之家 https://m.jb51.net/html5/587215.html 三.直播整体流程 直播整体流程大致可分为: 视频采集端:可以 ...
- [SRS流媒体]RTMP/HLS 直播服务器simple-rtmp-server安装
一个采用MIT协议授权的国产的简单的RTMP/HLS 直播服务器,其核心的价值理念在于简单高效. 使用方法: tep 1: build srs tar xf simple-rtmp-server-*. ...
- EasyDarwin如何支持点播和RTMP/HLS直播?EasyDSS!
2017年很长很长一段时间没有更新EasyDarwin开源项目了,虽然心里有很多EasyDarwin功能扩展的计划:比如同步录像.同步RTMP/HLS直播输出.拉模式转发优化.Onvif接入.GB28 ...
- 用nginx搭建http/rtmp/hls协议的MP4/FLV流媒体服务器
前前后后搭建了两三个星期,终于可以告一段落,nginx实在是有点强大.写一篇笔记来记录一下这个过程中的思路和解决方案. 一.搭建nginx平台: 基本是基于http://blog.csdn.net/x ...
- Android中直播视频技术探究之---视频直播服务端环境搭建(Nginx+RTMP)
一.前言 前面介绍了Android中视频直播中的一个重要类ByteBuffer,不了解的同学可以 点击查看 到这里开始,我们开始动手开发了,因为我们后续肯定是需要直播视频功能,然后把视频推流到服务端, ...
- 转: 基于nginx的hls直播系统
转自:http://blog.csdn.net/cjsafty/article/details/9108587 看点: 1. 详细解解答了 nginx rtmp配置过程. 前写了一篇基于nginx的h ...
- 如何使用Weave以及Docker搭建Nginx反向代理/负载均衡服务器
Hi, 今天我们将会学习如何使用 Weave 和 Docker 搭建 Nginx 的反向代理/负载均衡服务器.Weave 可以创建一个虚拟网络将 Docker 容器彼此连接在一起,支持跨主机部署及自动 ...
- EasyNVR H5直播流媒体解决方案前端构建之:如何播放自动适配RTMP/HLS直播播放
之前在进行EasyNVR多屏开发的时候,由于多屏功能不需要在手机端展示出来(pc多播放为RTMP,手机端播放为HLS),因此只注意到了引用videojs来进行rtmp的播放.由于不同项目需求不同,对h ...
- Centos7搭建nginx并提供外网访问
搭建nginx之后,80端口,其他机器无法访问 查询端口是否开启 firewall-cmd --query-port=80/tcp 永久开放80端口 firewall-cmd --permanent ...
随机推荐
- 【RAC】打完补丁后,发现只有一台rac可以启动,另一台无法启动
安装11Gr2单机asm后,打完11.2.0.3.7的psu后,发现启动不起来数据库,alert日志内容如下: Errors in file /u01/app/oracle/diag/rdbms/bd ...
- ctfhub技能树—信息泄露—备份文件下载—.DS_Store
打开靶机 查看页面信息 使用dirsearch进行扫描 访问该网页,下载文件 使用Linux系统打开文件 发现一个特殊文件,使用浏览器打开 拿到flag 二.使用Python-dsstore工具查看该 ...
- 树莓派3B装ubuntu server后开启wifi
树莓派官网选择ubuntu server下载映像 step 1: 使用SDFormatter格式化SD卡: step2: 使用win32diskimager工具将映像写入准备好的SD卡: step3: ...
- 发票校验BAPI_INCOMINGINVOICE_CREATE
CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE' EXPORTING headerdata = headerdata ...
- 欢迎来到 ZooKeeper 动物世界
本文作者:HelloGitHub-老荀 Hi,这里是 HelloGitHub 推出的 HelloZooKeeper 系列,免费有趣.入门级的 ZooKeeper 开源教程,面向有编程基础的新手. Zo ...
- 针对Fluent-Bit采集容器日志的补充
hello,之前我写过<一套标准的ASP.NET Core容器化应用日志收集分析方案>,在公司团队.微信公众号.Github上反映良好. 其中配置Fluent-bit使用Forward协议 ...
- git commit,启动文本编辑器
git commit中输入message的几种方式 - 简书 https://www.jianshu.com/p/ad461b99e860 在所有的git教程里,git commit肯定是一开始就会提 ...
- B-tree R-tree B+-tree indexes 索引顺序存取方法 ISAM MySQL实现拓展ISAM为MyISAM
High Performance MySQL, Third Edition by Baron Schwartz, Peter Zaitsev, and Vadim Tkachenko http://d ...
- Dubbo 总结:关于 Dubbo 的重要知识点
一 重要的概念 1.1 什么是 Dubbo? Apache Dubbo (incubating) |ˈdʌbəʊ| 是一款高性能.轻量级的开源Java RPC 框架,它提供了三大核心能力:面向接口的远 ...
- Windows VS Code 配置 Java 开发环境
Windows VS Code 配置 C/C++ 开发环境 准备 Windows [这个相信大家都有 笑: )] VS Code JDK 建议 JDK8以上(不包含JDK8,关于 Windows环境下 ...