rtmp协议的直播平台的搭建


先下载windows安装程序
VLC:http://rj.baidu.com/soft/detail/12124.html?ald
OBS: https://obsproject.com/download

 


yum -y install gcc gcc-c++ autoconf automake make openssl openssl-devel pcre-devel git

 

cd /opt
git clone https://github.com/arut/nginx-rtmp-module.git

wget http://nginx.org/download/nginx-1.8.1.tar.gz
tar -zxvf nginx-1.8.1.tar.gz
cd nginx-1.8.1
./configure --prefix=/usr/local/nginx --add-module=/opt/nginx-rtmp-module --with-http_ssl_module
make && make install

 


nginx配置文件

error_log logs/error.log debug;

events {
worker_connections 1024;
}

rtmp {
server {
listen 1935; #服务端口
chunk_size 4096; #数据传输块的大小
application live {
live on;
record off;
}
# application live2 {
# live on;
# record off;
# }
# video on demand
# application vod {
# play /var/flvs;
# }
# application vod_http {
# play http://192.168.31.185/vod;
# }
application hls {          #如果是多人直播可以创建多个application
  live on;
  hls on;
  hls_path /opt/hls; #视频文件存放位置。需要创建此目录(可放入视频进行播放
    }
  }
}
# HTTP can be used for accessing RTMP stats
http {
server {
listen 80;
# 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 /usr/local/nginx/nginx-rtmp-module/stat.xsl; ##注意需要把这个模块放到 nginx 目录中
}
location /hls {
  # Serve HLS fragments
  types {
  application/vnd.apple.mpegurl m3u8; #转换m3u8格式
  video/mp2t ts;
    }
  root /opt;
  add_header Cache-Control no-cache;
}
  location /dash {
# Serve DASH fragments
  root /opt;
  add_header Cache-Control no-cache;
  }
location / {
  root /opt/hls; #定义访问目录
  index index.html;
    }
  }
}
=================================================================================

把crossdomain.xml文件放到默认访问目录当中

mv crossdomain.xml /opt/hls

=============================================================

播放地址是:

http://ip/hls/*.m3u8

posted @ 2018-02-02 11:16  迷路的大雁  阅读(342)  评论(0编辑  收藏  举报