Nginx-based rtmp server (nginx-rtmp-module)

Source: Internet
Author: User
Tags xsl

First, download the library files that you need to rely on to install Nginx:

1.1, select Source Directory

Selected Directory/usr/local/rtmp

Cd/usr/local/rtmp

1.2, installing the Pcre Library

Cd/usr/local/rtmp

To www. pcre. org download pcre-8.37.tar.gz, then copy to/usr/local/hls

TAR-ZXVF pcre-8.37.tar.gz

CD pcre-8.37

./configure

Make

Make install

1.3, installing the Zlib library

Cd/usr/local/rtmp

To www. zlib. NET Download zlib-1.2.8.tar.gz, then copy to/usr/local/hls

TAR-ZXVF zlib-1.2.8.tar.gz CD zlib-1.2.8

./configure

Make

Make install

1.4, installing SSL

Cd/usr/local/rtmp

To www. OpenSSL. org download openssl-1.0.2g.tar.gz, then copy to/usr/local/hls

TAR-ZXVF openssl-1.0.2g.tar.gz

./config

Make

Make install

Two, install Nginx containing the Nginx-rtmp-module module

2.1, download and unzip Nginx

Download the stable version of nginx-1.8.1.tar.gz to nginx. org and copy it to/usr/local/rtmp

TAR-ZXVF nginx-1.8.1.tar.gz

2.2, download Nginx-rtmp-module

To https://github.com/arut/nginx-rtmp-module Download: nginx-rtmp-module.1.1.4.tar.gz then copy to/usr/local/rtmp

TAR-ZXVF nginx-rtmp-module.1.1.4.tar.gz

2.3, compile and install the nginx containing the Nginx-rtmp-module module

2.3.1, enter the nginx-1.8.1 source directory

Run the following command in turn:

./configure --prefix=/usr/local/nginx --add-module=/usr/local/rtmp/ nginx-rtmp-module.1.1.4 --with-http_ssl_module

Make-f Objs/makefile

Make-f Objs/makefile Install

Third, configure on-demand rtmp

3.1, open the nginx.conf configuration file in the nginx/conf directory

3.1.1 in http{

......

The following configuration is added to the end of the curly brace:

#配置rtmp状态页
server {
Listen 8080;

Location/stat {
Rtmp_stat all;
Rtmp_stat_stylesheet stat.xsl;
}

location/stat.xsl {
root/usr/local/rtmp/nginx-rtmp-module.1.1.4/; #在nginx-rtmp-module Source root directory
}
}

3.1.2, then add the following at the end of the nginx.conf:

#rtmp点播配置
rtmp {
server {
Listen 1935;
Chunk_size 4000;
Application VOD {
Play/usr/local/nginx/vod/flvs; #点播媒体文件存放目录
}
}
}

3.1.3, save the above configuration information.

3.2, configuring on-demand environment information

3.2.1, creating a Media folder

Mkdir/usr/local/nginx/vod/flvs

3.2.2, prepare the media file

Copy media files (such as oooo.flv) to the/usr/local/nginx/vod/flvs directory

3.2.3, preparing the Web page

Download jwplayer:www. jwplayer. com needs to be registered to download and obtain the corresponding license key (e.g., 601u+htlhuxp5lqpeztrlaabkwyx/94l3lracg==)

After downloading Jwplayer7.3.6.zip, extract to:/usr/local/nginx/html/

Set up the test page test.html, also put in the above directory:

  

3.3, start Nginx

3.3.1 Execution/usr/local/nginx/sbin/nginx

3.3.2, from the client page input Http://192.168.1.104:8080/stat get results:

3.3.3, from the client page input: Http://192.168.1.104/test.html get the following results:

Four, configure Live rtmp

4.1, open the nginx.conf configuration file in the nginx/conf directory

4.1.1 Add the following configuration information in the configuration file:

#rtmp直播配置

rtmp {

server {

Listen 1935;

Chunk_size 4000;

Application Live {

Live on;

}

}

}

4.1.2, such as 3.1.1 Join RTMP status configuration information

#配置rtmp状态页
server {
Listen 8080;

Location/stat {
Rtmp_stat all;
Rtmp_stat_stylesheet stat.xsl;
}

location/stat.xsl {
root/usr/local/hls/nginx-rtmp-module-master/; #在nginx-rtmp-module Source root directory
}
}

4.1.3, save the configuration information.

4.2 Configuring Resource Information

4.2.1, preparing the Web page

Download jwplayer:www. jwplayer. com requires registration to download and obtain the corresponding license key (for example: 601u+htlhuxp5lqpeztrlaabkwyx/94l3lracg= =

After downloading Jwplayer7.3.6.zip, extract to:/usr/local/nginx/html/

Set up the test page test.html, also put in the above directory:

4.3, start nginx, such as 3.3 in the start

4.4, Analog push flow

generate a live stream with ffmpeg simulation and push to the provisioned rtmp server

Ffmpeg–i/usr/local/nginx/vod/flvs/oooo.flv-strict-2-c:v libx264-c:a aac-f flv rtmp://192.168.1.104/live/test

Note: The source file must be an encoded format of H.264+AAC

where live is application; test is a live cache stream file, which needs to be consistent with the live cache file name in the configuration file. (for rtmp URL format, please check the relevant information yourself)

4.5, from the client page input: Http://192.168.1.104/test.html get similar to 3.3:

Nginx-based rtmp server (nginx-rtmp-module)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.