Nginx rtmp Module Implements HLS

Source: Internet
Author: User
Tags xsl

Nginx rtmp ffmpeg combo mimic HLS Live


A few days ago, Mister said to engage in a LAN live broadcast, think of the rtmp module mentioned before, holding a try to open the mentality of the


System environment:

[Email protected] html]# uname-a Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT i686 ATHL On i386 Gnu/linux[[email protected] html]# getconf Long_bit32


Nginx Environment:

1, Nginx:

http://nginx.org/download/

This test environment system version is 1.4.7


2. Nginx Module rtmp

Https://github.com/arut/nginx-rtmp-module/archive/master.zip


3. Multimedia Video Processing tool →ffmpeg

http://ffmpeg.org/releases/ffmpeg-2.6.1.tar.bz2


First, explain something.

Rtmp:rtmp (Real Time Messaging Protocol) Live Messaging Protocol is an open protocol for the development of audio, video, and data transmission between flash players and servers by Adobe Systems.

Then the Nginx rtmp module

Battle the people of Russia to develop a nginx streaming plug-in, in addition to live streaming audio and video streaming server with the common functions of the media

such as push-pull streaming media resources

Flv/mp4 VOD on-demand based on HTTP

Support for HLS (HTTP Live streaming) m3u8

HTTP-based operations (publish, play, record)

Can work well with existing streaming media servers and players

Online call FFmpeg streaming media for transcoding

H264/AAC audio and video encoding format support

Support for LINUX/BSD/MAC Systems

(from the network)



Installation Steps,

Nginx Installation

Download the rtmp module.

wget https://github.com/arut/nginx-rtmp-module/archive/master.zipunzip Master.zipwget http://nginx.org/download/ Nginx-1.4.7.tar.gztar xvf nginx-1.4.7.tar.gzcd nginx-1.4.7./configure--prefix=/usr/local/nginx--with-http_stub_ Status_module--with-http_ssl_module--with-http_flv_module--with-http_stub_status_module--with-http_gzip_static _module--add-module=/usr/local/src/nginx-rtmp-module-master--with-pcre=/usr/local/src/pcre-8.11 Make;make Install


FFmpeg installation

wget Http://ffmpeg.org/releases/ffmpeg-2.6.1.tar.bz2tar xvf ffmpeg-2.6.1.tar.bz2 cd ffmpeg-2.6.1

In this one compiled words will certainly be the error of the specific report what is wrong means that the lack of things, need to install Yasm

wget Http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gztar xvf yasm-1.2.0.tar.gzcd yasm-1.2.0./ Configuremake;make INSTALLCD ffmpeg-2.6.1./configure make; Make instal

L



The modified stuff is ready, now change the configuration file

Nginx configuration file needs to change the Nginx rtmp module inside has an nginx main configuration file

[

[Email protected] test]# pwd/usr/local/src/nginx-rtmp-module-master/test[[email protected] test]# lltotal 56- Rwxr-xr-x 1 root root 03:30 dump.sh-rwxr-xr-x 1 root root 1 Mar 03:30 ffstream.sh-rw-r--r--root root 1245 Mar 03:30 nginx.conf-rwxr-xr-x 1 root root 03:30 play.sh-rw-r--r--1 root root 499 Mar 03:30 READM E.mddrwxr-xr-x 2 root root 4096 Mar 03:30 rtmp-publisherdrwxr-xr-x 4 root root 4096 Mar 03:30 www

Copy the above master configuration file to the Nginx directory.


The nginx main configuration file is as follows

worker_processes  1;error_log  logs/error.log debug;events {     worker_connections  1024;} rtmp {    server {        listen  1936;        application myapp {             live on;              #record  keyframes;              #record_path  /tmp;            # record_max_size 128k;             #record_ interval 30s;             #record_suffix   .this.is.flv;             #on_publish http://localhost:8080/publish;            # on_play http://localhost:8080/play;              #on_record_done  http://localhost:8080/record_done;        }     }}rtmp {    server {         listen 1935;        chunk_size 4000;          #HLS         application hls  {            live on;             hls on;             hls_path /usr/local/nginx/html/hls;              hls_fragment 5s;        }    }} http {    server {        listen   8080;        location /hls {             # Serve HLS fragments             types {                 application/vnd.apple.mpegurl m3u8;                 video/mp2t ts;             }             root html;             expires -1; &nBsp;      }    }}http {    server  {        listen      8081;         location /stat {             rtmp_stat all;             rtmp_stat_stylesheet stat.xsl;        }         location /stat.xsl {             root /html/nginx-rtmp-module/;         }        location /control {             rtmp_control all;         }         #location  /publish {         #    return 201;        #}          #location  /play {         #    return 202;        #}          #location  /record_done {         #    return 203;        #}          #location  /rtmp-publisher {         #    root /html/nginx-rtmp-module/test;        # }        location / {             root /html/nginx-rtmp-module/test/www;         }    }}


Upload an FLV-formatted file to an HTML directory

Perform

Ffmpeg-re-i sample.flv-vcodec copy-acodec copy-f flv rtmp://192.168.3.105/hls/mystream

Then Page view Address

Http://192.168.3.105:8080/hls/mystream.m3u8




This article is from the "on the Road" blog, please be sure to keep this source http://xiaochengxiang.blog.51cto.com/2558908/1629596

Nginx rtmp Module Implements HLS

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.