Windows+nginx+rtmp+OBS搭建流媒体推流服务

本文详细介绍了如何使用Nginx和RTMP模块搭建推流服务器,包括下载、配置、OBS推流及拉流步骤,适合对实时媒体流感兴趣的开发者。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

推流服务器搭建

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

2、拉取hls地址:http://192.168.3.101:81/hls/111/index.m3u8

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值