GitHub - winshining/nginx-http-flv-module: Media streaming server based on nginx-rtmp-module. In addtion to the features nginx-rtmp-module supplies, HTTP-FLV, GOP cache and VHOST are supported now.

标签: | 发表时间:2019-05-01 21:49 | 作者:
出处:https://github.com

nginx-http-flv-module

Build Status

Media streaming server based on nginx-rtmp-module.

中文说明.

Donate if you like this module. Many thanks to you!

Buy Me A Coffee

Appreciation

Features

Features nginx-http-flv-module nginx-rtmp-module Remarks
HTTP-FLV (subscribe) x HTTPS-FLV and chunked response supported
GOP cache x
VHOST x
Omit listendirective See remarks There MUST be at least one listendirective
Audio-only support See remarks Won't work if wait_videoor wait_keyis on
Timing log for access x
JSON style stat x

Systems supported

  • Linux (recommended)/FreeBSD/MacOS/Windows (limited).

Players supported

Note

flv.jscan only run with browsers that support Media Source Extensions.

Prerequisites

  • GNU make for activating compiler on Unix-like systems to compile software.

  • GCC for compilation on Unix-like systems or MSVC for compilation on Windows.

  • GDB for debug on Unix-like systems.

  • FFmpegor OBSfor publishing media streams.

  • VLC(recommended) or flv.js(recommended) for playing media streams.

  • PCRE for NGINX if regular expressions needed.

  • OpenSSL for NGINX if encrypted access needed.

  • zlib for NGINX if compression needed.

Build

Note

nginx-http-flv-module has all features that nginx-rtmp-moduleprovides, so DON'Tcompile nginx-http-flv-module along with nginx-rtmp-module.

On Windows

For details of build steps, please refer to Building nginx on the Win32 platform with Visual C, and don't forget to add --add-module=/path/to/nginx-http-flv-modulein Run configure scriptstep.

On Unix-like systems

Download NGINXand nginx-http-flv-module.

Uncompress them.

cd to NGINX source directory & run this:

Compile the module into NGINX

    ./configure --add-module=/path/to/nginx-http-flv-module
make
make install

or

Compile the module as a dynamic module

    ./configure --add-dynamic-module=/path/to/nginx-http-flv-module
make
make install

Note

If the module is compiled as a dynamic module, the NGINXversion MUSTbe equal to or greater than 1.9.11.

Usage

For details of usages of nginx-rtmp-module, please refer to README.md.

Publish

For simplicity, transcoding is not used (so -c copyis used):

    ffmpeg -re -i MEDIA_FILE_NAME -c copy -f flv rtmp://example.com[:port]/appname/streamname

Note

  • Some legacy versions of FFmpegdon't support the option -c copy, the options -vcodec copy -acodec copycan be used instead.

The appnameis used to match an application block in rtmp block (see below for details).

The streamnamecan be specified at will.

The default port for RTMPis 1935, if some other ports were used, :portmust be specified.

Play

via HTTP-FLV

    http://example.com[:port]/dir?[port=xxx&]app=myapp&stream=mystream

Note

  • If ffplayis used in command line to play the stream, the url above MUSTbe enclosed by quotation marks, or arguments in url will be discarded (some shells not so smart will interpret "&" as "run in background").

  • If flv.jsis used to play the stream, make sure that the publishing stream is encoded properly, for flv.jssupports ONLY H.264 encoded video and AAC/MP3 encoded audio.

The diris used to match location blocks in http block (see below for details).

The default port for HTTPis 80, if some other ports were used, :portmust be specified.

The default port for RTMPis 1935, if some other ports were used, port=xxxmust be specified.

The appis used to match an application block, but if the requested appappears in several server blocks and those blocks have the same address and port configuration, host name matches server_namedirective will be additionally used to identify the requested application block, otherwise the first one is matched.

The streamis used to match the publishing streamname.

Example

Assume that listendirective specified in httpblock is:

    http {
    ...
    server {
        listen 8080; #not default port 80
        ...

        location /live {
            flv_live on;
        }
    }
}

And listendirective specified in rtmpblock is:

    rtmp {
    ...
    server {
        listen 1985; #not default port 1935
        ...

        application myapp {
            live on;
        }
    }
}

Then the url of playback based on HTTP is:

    http://example.com:8080/live?port=1985&app=myapp&stream=mystream

Note

Since some players don't support HTTP chunked transmission, it's better to specify chunked_transfer_encoding off;in location where flv_live on;is specified in this case, or play will fail.

via RTMP

    rtmp://example.com[:port]/appname/streamname

via HLS

    http://example.com[:port]/dir/streamname.m3u8

via DASH

    http://example.com[:port]/dir/streamname.mpd

Sample Pictures

RTMP ( JW Player) & HTTP-FLV ( VLC)

RTMP & HTTP-FLV

HTTP-FLV ( flv.js)

HTTP-FLV

Packages for nginx-http-flv-module

Please refer to nginx-http-flv-module-packages.

Example nginx.conf

Note

The directives rtmp_auto_push, rtmp_auto_push_reconnectand rtmp_socket_dirwill not function on Windows except on Windows 10 17063 and later versions, because relayin multiple processes mode needs help of Unix domain socket, please refer to Unix domain socket on Windows 10for details.

It's better to specify the directive worker_processesas 1, because ngx_rtmp_stat_modulemay not get statistics from a specified worker process in multi-processes mode, for HTTP requests are randomly distributed to worker processes. ngx_rtmp_control_modulehas the same problem. The problem can be optimized by this patch per-worker-listener.

In addtion, vhostfeature is not perfect in multi-processes mode yet, waiting to be fixed. For example, the following configuration is OK in multi-processes mode:

    rtmp {
    ...
    server {
        listen 1935;

        application myapp {
            ...
        }
    }

    server {
        listen 1935;
        server_name localhost;

        application myapp {
            ...
        }
    }
}

While the following configuration doesn't work for play requests distinated to the port 1945 of non-publisher worker processes on which some streams are published:

    rtmp {
    ...
    server {
        listen 1935;

        application myapp {
            ...
        }
    }

    server {
        listen 1945;
        server_name localhost;

        application myapp {
            ...
        }
    }
}

Example configuration

    worker_processes  1; #should be 1 for Windows, for it doesn't support Unix domain socket
#worker_processes  auto; #from versions 1.3.8 and 1.2.5

#worker_cpu_affinity  0001 0010 0100 1000; #only available on FreeBSD and Linux
#worker_cpu_affinity  auto; #from version 1.9.10

error_log logs/error.log error;

#if the module is compiled as a dynamic module and features relevant
#to RTMP are needed, the command below MUST be specified and MUST be
#located before events directive, otherwise the module won't be loaded
#or will be loaded unsuccessfully when NGINX is started

#load_module modules/ngx_http_flv_live_module.so;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    keepalive_timeout  65;

    server {
        listen       80;

        location / {
            root   /var/www;
            index  index.html index.htm;
        }

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

        location /live {
            flv_live on; #open flv live streaming (subscribe)
            chunked_transfer_encoding  on; #open 'Transfer-Encoding: chunked' response

            add_header 'Access-Control-Allow-Origin' '*'; #add additional HTTP header
            add_header 'Access-Control-Allow-Credentials' 'true'; #add additional HTTP header
        }

        location /hls {
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }

            root /tmp;
            add_header 'Cache-Control' 'no-cache';
        }

        location /dash {
            root /tmp;
            add_header 'Cache-Control' 'no-cache';
        }

        location /stat {
            #configuration of push & pull status

            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root /var/www/rtmp; #specify in where stat.xsl located
        }

        #if JSON style stat needed, no need to specify
        #stat.xsl but a new directive rtmp_stat_format

        #location /stat {
        #    rtmp_stat all;
        #    rtmp_stat_format json;
        #}

        location /control {
            rtmp_control all; #configuration of control module of rtmp
        }
    }
}

rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir /tmp;

rtmp {
    out_queue           4096;
    out_cork            8;
    max_streams         128;
    timeout             15s;
    drop_idle_publisher 15s;

    log_interval 5s; #interval used by log module to log in access.log, it is very useful for debug
    log_size     1m; #buffer size used by log module to log in access.log

    server {
        listen 1935;
        server_name www.test.*; #for suffix wildcard matching of virtual host name

        application myapp {
            live on;
            gop_cache on; #open GOP cache for reducing the wating time for the first picture of video
        }

        application hls {
            live on;
            hls on;
            hls_path /tmp/hls;
        }

        application dash {
            live on;
            dash on;
            dash_path /tmp/dash;
        }
    }

    server {
        listen 1935;
        server_name *.test.com; #for prefix wildcard matching of virtual host name

        application myapp {
            live on;
            gop_cache on; #open GOP cache for reducing the wating time for the first picture of video
        }
    }

    server {
        listen 1935;
        server_name www.test.com; #for completely matching of virtual host name

        application myapp {
            live on;
            gop_cache on; #open GOP cache for reducing the wating time for the first picture of video
        }
    }
}

相关 [github winshining nginx] 推荐:

GitHub - winshining/nginx-http-flv-module: Media streaming server based on nginx-rtmp-module. In addtion to the features nginx-rtmp-module supplies, HTTP-FLV, GOP cache and VHOST are supported now.

- -
MUSTbe enclosed by quotation marks, or arguments in url will be discarded (some shells not so smart will interpret "&" as "run in background").. ngx_rtmp_stat_modulemay not get statistics from a specified worker process in multi-processes mode, for HTTP requests are randomly distributed to worker processes.

RTMP 流媒体服务器 GitHub - arut/nginx-rtmp-module: NGINX-based Media Streaming Server

- -
几个优秀的RTMP 流媒体服务器:. NGINX-based Media Streaming Server:基于Nginx插件. SRS(Simple RTMP Server) over state-threads:基于C++. livego:基于go语言. node-rtsp-rtmp-server:基于 Node.js.

Home · JohnLangford/vowpal_wabbit Wiki · GitHub

- -
There are two ways to have a fast learning algorithm: (a) start with a slow algorithm and speed it up, or (b) build an intrinsically fast learning algorithm.

GitHub - jgraph/drawio: Source to www.draw.io

- -
draw.io supports IE 11, Chrome 32+, Firefox 38+, Safari 9.1.x, 10.1.x and 11.0.x, Opera 20+, Native Android browser 5.1.x+, the default browser in the current and previous major iOS versions (e.g.

nginx配置ssl

- - 邢红瑞的blog
先生成网关证书 ,仿照CA模式.

Nginx安装

- - 企业架构 - ITeye博客
nginx可以使用各平台的默认包来安装,本文是介绍使用源码编译安装,包括具体的编译参数信息. 正式开始前,编译环境gcc g++ 开发库之类的需要提前装好,这里默认你已经装好. ububtu平台编译环境可以使用以下指令. centos平台编译环境使用如下指令. 一般我们都需要先装pcre, zlib,前者为了重写rewrite,后者为了gzip压缩.

Nginx GZip 压缩

- - 开心平淡对待每一天。热爱生活
  Nginx GZip 模块文档详见: http://wiki.nginx.org/HttpGzipModule 常用配置片段如下:. # 压缩比例,比例越大,压缩时间越长. 默认是1 gzip_types. text/css text/javascript; # 哪些文件可以被压缩 gzip_disable.

Nginx 限流

- - 鸟窝
电商平台营销时候,经常会碰到的大流量问题,除了做流量分流处理,可能还要做用户黑白名单、信誉分析,进而根据用户ip信誉权重做相应的流量拦截、限制流量. Nginx自身有的请求限制模块 ngx_http_limit_req_module、流量限制模块 ngx_stream_limit_conn_module基于令牌桶算法,可以方便的控制令牌速率,自定义调节限流,实现基本的限流控制.

git和github简介(上)

- linyehui - 没做完,没准备好
在此贴上本人在Web标准化交流会6月25日北京站的主题分享. 在线PPT:http://jinjiang.github.com/slides/learning-git/. PPT源码:https://github.com/Jinjiang/slides/tree/gh-pages/learning-git.

Github使用指南(转)

- - CSDN博客推荐文章
来自:https://github.com/neuola/neuola-legacy/wiki/github%E4%BD%BF%E7%94%A8%E6%8C%87%E5%8D%97. 如果你只是想了解 github 的使用,请跳到 Github 简介一节. 作为程序员大军之一,想必大家有这样的经历吧.