Setting up RTMP server based on nginx

Install nginx

Download ngnix source

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

Compile Installation

./configure --add-module=../nginx-rtmp-module-master
make
sudo make install

The default installation path is/usr/local/nginx, run. /sbin/nginx

Open the browser and type in the address bar: localhost, if Welcome to nginx is displayed, the installation is successful

 

Configure rtmp service

Open. /conf/nginx.conf to add the RTMP configuration

worker_processes  1;

events {
    worker_connections  1024;
}
rtmp {                #RTMP Service
    server {
        listen 6666;  #//Service Port 
        chunk_size 4096;   #//Size of data transfer block

        application vod {  #//On Demand Service
        play /opt/video/vod; #//Video file storage location.
        }

       application live{ #First added live field
        live on;
       }
    }
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   html;
            index  index.html index.htm;
        }
        location /stat {     #The location field added at the second place.
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl { #The location field added at the second place.
            root /usr/local/nginx/nginx-rtmp-module/;
        }

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

Configuration directory/opt/video/vod is where the video files are stored. Place a video file, test.mp4, for testing

Open the video playback software and fill in rtmp://localhost:6666/vod/test.mp4 for the playback address

 

Live is a live broadcasting service. If you plan to make multiple channels live, you can have any name of live_2 or live_2.The second is to add two location fields, the contents of which should be viewed directly from the file.

Tags: Operation & Maintenance Nginx git github sudo

Posted on Thu, 07 Nov 2019 11:40:31 -0800 by Jiin