beebe_3 发表于 2018-11-9 12:15:12

centos使用一键lnmp+nginx-rtmp-module插件,使用obs推流到nginx

  1\安装一键lnmp1.3
  
  centos安装一键lnmp1.3
  然后进入一键lnmp1.3的安装解压目录
  例如:   lnmp1.3-full/src
  中找到   nginx-1.10.0.tar.gz
  解压
  2\安装nginx-rtmp-module插件,并作相关配置
  1>执行nginx -V 查看当前编译参数;
  停止nginx服务;
  重新编译安装nginx,编译时把之前的参数复制下来然后在后面增加支持nginx-rtmp-module插件;
  重新启动nginx服务;
  2>修改nginx配置(nginx.conf)使之支持rtmp和hls;
  在server模块中增加:
  location /hls {
  types {
  application/vnd.apple.mpegurl m3u8;
  video/mp2t ts;
  }
  alias /home/wwwroot/default/hls/live01/;#视频流文件目录(自己创建)
  expires -1;
  add_header Cache-Control no-cache;
  }
  在末尾增加模块:
  rtmp {
  server {          listen 1935;#监听的端口
  chunk_size 4000;
  application hls {#rtmp推流请求路径
  live on;
  hls on;
  hls_path /home/wwwroot/default/hls/live01; #视频流文件目录(自己创建)
  hls_fragment 3s;
  }
  }
  }
  
  
  3\在其它电脑安装obs,
  使用obs推到 rtmp://服务器地址:1935/hls/    流秘钥 live01
  4\可以使用vlc播放或在网页中播放。
  媒体流播放地址为http://服务器地址/hls/live01.m3u8
  网页中视频地址为http://服务器地址/hls/live01.m3u8
  网页中播放需要使用插件,我使用的是ckplayer
  
  
  
  var flashvars={
  f:'ckplayer/m3u8.swf',
  a:'http://10.1.1.196/hls/live01.m3u8',
  s:4,
  c:0
  };
  var params={bgcolor:'#FFF',allowFullScreen:true,allowScriptAccess:'always',wmode:'transparent'};
  var video=['http://10.1.1.196/hls/live01.m3u8'];
  CKobject.embed('ckplayer/ckplayer.swf','a1','ckplayer_a1','768','432',false,flashvars,video,params);
  
  


页: [1]
查看完整版本: centos使用一键lnmp+nginx-rtmp-module插件,使用obs推流到nginx