推流服务器搭建
1、下载nginx-1.2.11.3-Gryphon 地址:http://nginx-win.ecsds.eu/download/
2、下载rtmp模块与nginx.exe放在同一目录
git clone GitHub - arut/nginx-rtmp-module: NGINX-based Media Streaming Server
3、配置文件conf/nginx-win.conf
rtmp{
server {
listen 1935;
chunk_size 4096;
application hls {
live on;
hls on;
hls_path tmp/hls;
hls_fragment 1s;
hls_cleanup on;
hls_continuous on;
hls_playlist_length 3s;
hls_nested on;
}
}
}
http{
server {
listen 81;
server_name localhost;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
}
location /control {
rtmp_control all;
}
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
alias tmp/hls;
expires -1;
add_header Cache-Control no-cache;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
}
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root nginx-rtmp-module/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
4、将相应端口81、1935开放
5、开启服务(cmd在nginx.exe目录下)
nginx.exe -c conf\nginx-win.conf
6、关闭服务可直接杀进程
7、注:如果视频切片存放文件目录无法生成,手动建立(第3部分中 tmp/hls 文件目录)
OBS推流
1、点击设置->推流
服务器:将47.108.76.168改为本地服务器ip,/live改为/hls,串流密码随意设置,如111
2、窗口采集,选定要推流的画面,页面
3、开始推流
拉流(ip换一换哟)
1、拉取rtmp地址: rtmp://192.168.3.101:1935/hls/111