Nginx rtmp Server

Source: Internet
Author: User
Tags openssl library xsl

NginxOfRtmpProtocol server

By ahuner

The following configuration allows nginx to receive rtmp streams and play real-time videos on the web.

1. OpenSSL Installation

Nginx requires the http_ssl_module module and the OpenSSL library.

Opensll: http://www.openssl.org/

Latest stable version: openssl-1.0.1e

Modify the code for the three files, md2test. C, rc5test. C, jpaketest. c In openssl-1.0.1e \ test

Change dummytest. C to # include "dummytest. c ".

Compile:

Chmod + x config

Compile static library

./Config -- prefix =/usr/local -- openssldir =/usr/local/opensll

Make & make install

Compile a dynamic library

./Config shared -- prefix =/usr/local -- openssldir =/usr/local/opensll

Make clean

Make & make install

2. nginx rtmp Module

Download nginx-rtmp-Module

Https://github.com/arut/nginx-rtmp-module

3. Install nginx

./Configure \

-- Prefix =/usr/local/nginx \

-- Sbin-Path =/usr/local/nginx \

-- Conf-Path =/usr/local/nginx. conf \

-- PID-Path =/usr/local/nginx. PID \

-- Error-log-Path =/usr/local/nginx/logs/error. log \

-- With-PCRE = ../pcre-8.31 \

-- With-zlib = ../zlib-1.2.7 \

With-http_dav_module \

With-http_flv_module \

With-http_stub_status_module \

Without-http_scgi_module \

Without-http_uwsgi_module \

Without-http_gzip_module \

Without-http_ssi_module \

Without-http_proxy_module \

Without-http_memcached_module \

Without-http_empty_gif_module \

Without-mail_pop3_module \

Without-mail_imap_module \

Without-mail_smtp_module \

With-http_ssl_module \

-- With-OpenSSL =/project/openssl-1.0.1e \

-- Add-module =/project/nginx-rtmp-module-Master

Note:/project/openssl-1.0.1e is the source code directory of OpenSSL, nginx will be automatically compiled when the connection OpenSSL.

Make & make install

4. nginx. conf

Configuration file:

# User nobody;
Worker_processes 1;

Error_log logs/error. Log debug;
# Error_log logs/error. Log notice;
# Error_log logs/error. Log Info;

# PID logs/nginx. PID;

Events {
Worker_connections 1024;
}

Rtmp {
Server {
Listen 1935;

Chunk_size 4096;

Application MyApp {
Live on;
}
}
}

HTTP {
Server {
Listen 80;

Location/STAT {
Rtmp_stat all;
Rtmp_stat_stylesheet Stat. XSL;
}

Location/STAT. XSL {
Root/project/nginx-rtmp-module-master /;
}

Location /{
Root/project/nginx-rtmp-module-master/test/rtmp-publisher;
}
}
}

5. streaming

"Rtmp: // 192.168.1.102/MyApp" indicates URL, and "test1" indicates stream

Streaming Method 1: FFMPEG-Re-I ~ /2012.flv-f flv rtmp: // 192.168.1.102/MyApp/test1

Streaming Method 2: Adobe Flash Media live Encoder

6. Live Video Playback

Use an example provided by nginx-rtmp-module to modify player.html in the test/rtmp-publisherdirectory.

<! Doctype HTML>

<HTML>

<Head>

<Title> rtmp player </title>

<SCRIPT type = "text/JavaScript" src = "swfobject. js"> </SCRIPT>

<SCRIPT type = "text/JavaScript">

VaR flashvars = {

Streamer: 'rtmp: // 192.168.1.102/myapp ',

File: 'test1'

};

Swfobject. embedswf ("rtmpplayer.swf", "rtmp-publisher", "500", "400", "9.0.0 ",

Null, flashvars );

</SCRIPT>

</Head>

<Body>

<Div id = "rtmp-publisher">

<P> Flash not installed </P>

</Div>

</Body>

</Html>

Access http: // 192.168.1.102/player.html

 

Reference

Nginx rtmp Function Research:

Http://blog.csdn.net/cccallen/article/details/8440191

Nginx rtmp Server

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.