Nginx 搭建直播流服务

Stella981
• 阅读 641

搭建直播流服务器

技术

  • Nginx
  • nginx-rtmp-module-1.1.11 (nginx 插件)

步骤

  1. 下载nginx 和 nginx-rtmp-module 源文件

  2. 解压 nginx 和 nginx-rtmp-module

  3. ./configure --add-module=/home/shichangcheng/live/nginx-rtmp-module-1.1.11(将nginx第三方模块加入nginx)

  4. make ; make install;

  5. 配置nginx.conf

    http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # hls living location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root /usr/local/nginx/html/nginx-rtmp-module/; } location /control { rtmp_control all; } location /hls { types{ application/vnd.apple.mpegurl m3u8; video/mp2t ts; } root /home/shichangcheng/live/my-app; } } }

    rtmp { server { listen 1935; application hls { live on; hls on; hls_path /home/shichangcheng/live/my-app/hls; hls_fragment 5s; } application live{ live on; max_connections 1024; allow play all; record_path /home/shichangcheng/live/my-app/live; recorder audio { record audio; record_suffix -%d-%b-%y-%T.flv; } recorder chunked { record all; #record_max_size 5120K;
    record_interval 15s; record_path /home/shichangcheng/live/my-app/live/chunked; } } } }

遇到的问题

  1. liunx 的权限
  2. nginx user 修改为root
  3. rtmp 中 record_path 保存客户端采集视频信息推动到服务器的地址,需要注意该文件的读写权限。
  4. 防火墙 iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 1935 -j ACCEPT

推流地址

rtmp://123.206.231.130/hls/(movie)
(movie)为表示生成流文件的名字

播放地址

rtmp地址:rtmp://123.206.231.130/hls/(movie)
hvl 地址:http://123.206.231.138/hls/movie.m3u8

直播协议

  1. rtmp :rtmp 延时较低,需要使用flash,或者解码器才能播放。
  2. hlv :hlv 延时较高,自己测未进过cdn一般优化,延时5。移动端网页播放使用HLV协议。

客户端

  1. 直播工具可以使用金山云的DEMO
  2. 播放器
  • H5 只能使用 hlv 地址
  • 金山云提供的播放SDK
  • PC客户端 VLC Media Player

我的博客

点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
芝士年糕 芝士年糕
1年前
nginx 启动、停止、关闭
使用3A服务器搭建的centos系统安装nginx教程在我的往期博客中1,nginx指定配置文件/usr/local/nginx/sbin/nginxc/usr/local/nginx/conf/nginx.conf1c参数指定了要加载的nginx配置文件路径1,从容停止Nginx:killQUIT主进程号2,快速停止Nginx:kil
Stella981 Stella981
2年前
Nginx配置https
一、开启nginx的ssl模块1.未安装过nginx,编译安装配置参数如下:./configure\prefix/usr/local/nginx\withpcre\withhttp\_ssl\_modulessl模块\withhttp\_stub\_status\_module\wit
Wesley13 Wesley13
2年前
4. Nginx模块
Nginx官方模块1.ngx\_http\_stub\_status\_modulehttp://nginx.org/en/docs/http/ngx\_http\_stub\_status\_module.html。(https://www.oschina.net/action/GoToLink?urlhttp%3A%2
Stella981 Stella981
2年前
Linux下nginx服务器环境搭建
1.安装前准备1.Linux环境:本文采用的环境是centerOS6.02.nginx下载地址:http://nginx.org/en/download.html3.nginx版本:nginx1.9.92.nginx环境搭建过程1).解压下载好的nginx文件1.①进
Stella981 Stella981
2年前
Nginx之使用nginx搭建简单的文件服务器
  使用nginx可以搭建简单文件服务器  安装nginx(不详述)    修改配置文件/usr/local/nginx/conf/nginx.confuserroot;worker_processes1;error_loglogs/error.log;pidlog
Stella981 Stella981
2年前
Nginx反向代理upstream模块介绍
!(https://oscimg.oschina.net/oscnet/1e67c46e359a4d6c8f36b590a372961f.gif)!(https://oscimg.oschina.net/oscnet/819eda5e7de54c23b54b04cfc00d3206.jpg)1.Nginx反
Stella981 Stella981
2年前
Nginx
!(https://imagestatic.segmentfault.com/255/117/25511790966008dc5b00fd8)Nginx进程模型分析在介绍Nginx的进程模型之前我们先来给大家解释下一些常见的名词,这能辅助我们更好的了解Nginx的进程模型。作为Web服务器,设计的初衷就是为了能够处理更多的客户端的请
Wesley13 Wesley13
2年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
3个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这