Centos7 搭建Nginx+rtmp+hls直播推流服务器
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Centos7 搭建Nginx+rtmp+hls直播推流服务器,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2718字,纯文字阅读大概需要4分钟。
内容图文
![Centos7 搭建Nginx+rtmp+hls直播推流服务器](/upload/InfoBanner/zyjiaocheng/937/eae71a0d8ba44ab1ab62f0d6b35956fb.jpg)
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-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
使用vim命令打开 nginx.conf,输入 i 进入编辑状态
[root~]# vim /usr/local/nginx/conf/nginx.conf
# 在http节点同级加上rtmp配置: rtmp { server { listen 1935; chunk_size 2048; application rtmplive { live on; record off; } # HLS 配置(可选) application hls { live on; hls on; hls_path /tmp/hls; #需要手动创建路径 } } } #http配置 HLS配置需要 http { server { listen 8080; # 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/; } 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
[root~]# nginx -s reload
4 推流
使用obs推流
url填写 rtmp://[服务器ip]:[端口]/[nginx配置中rtmp的application名称],如 rtmp://10.129.0.100:1935/hls
如配置HLS,需填写串流码,名称随意,如 demo,这个名称在HLS方式拉流时会用到
5 拉流
使用vlc拉流
填写网络URL 如 http://10.129.0.100:8080/hls/demo.m3u8
注意m3u8的文件名与推流时填的串流码一致
centos7 搭建rtmp+hls直播流服务器及rtmp转hls直播流(nginx+nginx-rtmp-module-master+obs)
nginx nginx-rtmp-module 基于rtmp协议实现公网推流拉流
内容总结
以上是互联网集市为您收集整理的Centos7 搭建Nginx+rtmp+hls直播推流服务器全部内容,希望文章能够帮你解决Centos7 搭建Nginx+rtmp+hls直播推流服务器所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。