nginx Rtmp 모듈을 사용하여 자신 만의 라이브 서버 구축

소스 코드 다운로드

먼저 소스 코드와 일반적으로 사용되는 컴파일 도구 (gcc 등)를 준비합니다.

mkdir /opt/git # 这里我偷懒直接把源码下载到这了,大家自行找地方
cd /opt/git
git clone https://github.com/arut/nginx-rtmp-module.git # 下载 nginx-rtmp-module
wget http://nginx.org/download/nginx-1.17.7.tar.gz # 下载nginx,这里用的最新测试版,推荐大家用稳定版
tar -zxvf nginx-1.17.7.tar.gz
cd nginx-1.17.7/
./configure --prefix=/opt/nginx1.17 --add-module=/opt/git/nginx-rtmp-module # 这里是重点,添加了一个mod
make && make install # 编译安装
cd /opt/nginx1.17/
vim /opt/nginx1.17/conf/nginx.conf # 开始配置
# 全部注释或删除 /opt/nginx1.17/conf/nginx.conf 中的配置
# 在配置的最高层,可以是开头或结尾,添加下面的包含
include rtmp.conf

rtmp 구성 파일 편집

vim /opt/nginx1.17/conf/rtmp.conf

다음 구성 추가

rtmp {
    server {
        listen 8883;  # 我使用的自定义端口,而不是标准的1935

        application vod {
            play /opt/nginx1.17/video;
        }

        application live{ #第一处添加的直播字段,添加了一个live应用,里面可以有很多直播间
            live on;
        }
    }
}

http {
    #include      mime.types;
    #default_type  application/octet-stream;
    #sendfile        on;
    #keepalive_timeout  65;
    server {
        listen      8884; #用于查看直播状态和观看直播的web页面
        server_name  localhost;

        location /stat { # 状态查看页面实例
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
           root /opt/git/nginx-rtmp-module/;
        }
	
	location /control {
            rtmp_control all;
        }

	location /rtmp-publisher {
            root /opt/git/nginx-rtmp-module/test;
        }
	
	location / { # 直播观看页面实例
            root /opt/git/nginx-rtmp-module/test/www;
        }

        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
            root  html;
        }
    }
}

방화벽 켜기

firewall-cmd --add-port=8883/tcp
firewall-cmd --add-port=8883/udp
firewall-cmd --add-port=8884/tcp
firewall-cmd --add-port=8884/udp

지금까지 서버가 구축되었습니다.

사용하다

obs는
rtmp : // [ip 주소] : 8883 / live로 푸시합니다 .

웹 페이지
http : // (ip address] : 8884 / stat 에서 푸시 상태를 확인하세요.

주문형 비디오는 서버의
/opt/nginx1.17/video에 배치됩니다.

vnc 스트림보기, 네트워크 URL 열기
rtmp : // [ip 주소] : 8883 / live

웹에서 푸시 스트리밍 및 주문형 비디오를 볼 수 있지만
http : // [ip 주소] : 8884 는 사용하지 않습니다 .

추천

출처blog.csdn.net/zoollcar/article/details/104814367