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

浙公網安備 33010602011771號