Nginx builds rtmp live server implementation code

Nginx builds rtmp live server implementation code

1. Create a new rtmp directory in the nginx source directory and enter git clone https://github.com/arut/nginx-rtmp-module.git

2. Recompile nginx code as follows

./configure --prefix=/usr/local/nginx-1.2.9/ --add-module=./rtmp/nginx-rtmp-module --with-http_ssl_module --with-pcre=/lamp_source/pcre-8.38;
make;make install;
#Reinstall nginx

3. After completing the installation.

Open nginx.conf and add the following code after http{server...}

rtmp{
    server{
        listen 1935;
        chunk_size 4000;
        application hls
            live on;
            hls on;
            hls_path /your server path is used to store cache files. Must be writable;
            hls_fragment 5s;
        }
    }
}

Then create a new host configuration

server {
 
    listen 8851;
    location /index.html {
    root /website storage directory;
}
    location / {# return 403;
      # Serve HLS fragments
      types {
        application/vnd.apple.mpegurl m3u8;
        video/mp2t ts;
      }
      root /same as above, for caching;
      expires -1;
    }
  }

After completing the above configuration. Just download a software called open broadcaster software and use it to push the stream (note that you can also use ffmpeg to push the stream). Software usage as shown in screenshots

Then click Start Streaming.

Download and open VLC player (streaming). Enter rtmp://your website:1935/hls/the password in the picture above and it will be ok. Successful online live broadcast

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of configuring Nginx+RTMP+HLS+HTTPFLV server in Ubuntu 18.04 to realize on-demand/live broadcast/recording functions
  • Detailed steps to build nginx+rtmp live server on Mac
  • How to use Nginx to carry rtmp live server

<<:  Solution to the problem of Failed when configuring IDEA to connect to MYSQL database

>>:  Vue implements a simple shopping cart example

Recommend

How to view the storage location of MySQL data files

We may have a question: After we install MySQL lo...

js basic syntax and maven project configuration tutorial case

Table of contents 1. js statement Second, js arra...

In-depth explanation of JavaScript this keyword

Table of contents 1. Introduction 2. Understand t...

A brief introduction to bionic design in Internet web design

When it comes to bionic design, many people will t...

Summary of standard usage of html, css and js comments

Adding necessary comments is a good habit that a ...

React uses routing to redirect to the login interface

In the previous article, after configuring the we...

MySQL functional index optimization solution

When using MySQL, many developers often perform f...

How to set an alias for a custom path in Vue

How to configure custom path aliases in Vue In ou...

5 Simple XHTML Web Forms for Web Design

Simple XHTML web form in web design 5. Technique ...

How to create a view on multiple tables in MySQL

In MySQL, create a view on two or more base table...