Giter VIP home page Giter VIP logo

blss's People

Contributors

gnolizuh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blss's Issues

完善README

  • 如何使用多进程模式
  • 如何输出监控日志
  • 如何搭建直播源站
  • 如何搭建直播CDN集群
  • 如何使用RTMP HEVC/H.265

Build error nginx 1.15.6, Debian 9, GCC 6.3

Build fails hard during make.

Debian 9.6
gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)
nginx 1.15.6
Latest module version from git

$ make
make -f objs/Makefile
make[1]: Verzeichnis „/home/stream/blss/build/nginx-1.15.6“ wird betreten
*truncated*
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g   -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../BLSS -I objs -I src/http -I src/http/modules \
        -o objs/addon/BLSS/ngx_rtmp.o \
        ../BLSS/ngx_rtmp.c
../BLSS/ngx_rtmp.c: In function ‘ngx_rtmp_init_listening’:
../BLSS/ngx_rtmp.c:1251:33: error: passing argument 1 of ‘ngx_clone_listening’ from incompatible pointer type [-Werror=incompatible-pointer-types]
         if (ngx_clone_listening(cf, ls) != NGX_OK) {
                                 ^~
In file included from src/core/ngx_core.h:90:0,
                 from ../BLSS/ngx_rtmp.c:9:
src/core/ngx_connection.h:213:11: note: expected ‘ngx_cycle_t * {aka struct ngx_cycle_s *}’ but argument is of type ‘ngx_conf_t * {aka struct ngx_conf_s *}’
 ngx_int_t ngx_clone_listening(ngx_cycle_t *cycle, ngx_listening_t *ls);
           ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
objs/Makefile:1296: die Regel für Ziel „objs/addon/BLSS/ngx_rtmp.o“ scheiterte
make[1]: *** [objs/addon/BLSS/ngx_rtmp.o] Fehler 1
make[1]: Verzeichnis „/home/stream/blss/build/nginx-1.15.6“ wird verlassen
Makefile:8: die Regel für Ziel „build“ scheiterte
make: *** [build] Fehler 2

请问http flv 部分的http server和 location怎么配置呢?

请问http flv 部分怎么配置呢? 我的配置如下,但是nginx 日志有错误.

2018/02/09 18:54:18 [error] 25162#0: *49 open() "/opt/app/nginx2/html/test/robin-test" failed (2: No such file or directory), client: 192.168.6.15, server: 192.168.4.133, request: "GET /test/robin-test HTTP/1.0", host: "192.168.4.133:80"

 server {
    listen       80;
    server_name  192.168.4.133;
    location / {
       http_flv on;
    }
}

rtmp {
server {
listen 1935 reuseport;
#listen 1935;

    service cctv {
        #hostname pub rtmp publish.com;      # match rtmp push domain
        hostname sub rtmp 192.168.4.133;     # match rtmp pull domain
        hostname sub http_flv 192.168.4.133;  # match http-flv pull domain

        application test {
            live on;
            gop_cache on;
            gop_cache_count 1;

            pull rtmp://192.168.4.131:1935/test;
        }
    }
}

}

Bad config

Hi,
I have config which works on nginx-rtmp installation. After install BLSS there is an error:

nginx: [emerg] "application" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:66

There is part of my config where error occurs:
`
rtmp {
server {
listen 1935;
ping 30s;
notify_method get;
drop_idle_publisher 5s;
respawn_timeout 2s;

        application livepass {
        live on;
        record off;
        on_publish http://localhost:8080/auth.php;
        notify_method get;

        hls on;
        hls_fragment 10s;
        hls_playlist_length 30s;

        }

    }

}
`

What is wrong with 'application' ?

Cannot play stream

Hi,
Im trying to use your module to implement a streaming server.
Here is my config (basically the same as in your readme)

worker_processes 1;   # multi-worker process mode
relay_stream hash;    # stream relay mode

events {
worker_connections 1024;
}


rtmp {
    server {
        listen 1935 reuseport;

        service cctv {
            hostname pub rtmp localhost;      # match rtmp push domain
            hostname sub rtmp localhost;     # match rtmp pull domain
            hostname sub http_flv localhost;  # match http-flv pull domain

            application live {
                live on;
                gop_cache on;
                gop_cache_count 5;  # cache 5 GOPs

                hls on;
                hls_fragment 10s;
                hls_playlist_length 30s;
            }
        }
    }
}

Streaming into the server with ffmpeg works fine. Here is my command:
./ffmpeg -f pulse -ac 2 -i default -f x11grab -framerate 25 -video_size 1440x1080 -i :0.0+0,0 -async 1 -vsync 1 -c:v libx264 -crf 23 -preset superfast -vf "format=yuv420p" -g 60 -tune zerolatency -movflags +faststart -fflags +genpts -avoid_negative_ts make_zero -c:a aac -b:a 128k -ar 44100 -f flv rtmp://localhost/live/test

But when i try to play the stream with ffplay:
./ffplay rtmp://localhost/live/test

RTMP_ReadPacket, failed to read RTMP packet headersq=    0B f=0/0   
rtmp://localhost/live/test: Unknown error occurred

Here is the log:

2018/09/28 19:29:25 [info] 5465#0: *1 client connected '127.0.0.1'
2018/09/28 19:29:25 [info] 5465#0: *1 connect: host='localhost' app='live' args='' flashver='' swf_url='' tc_url='rtmp://localhost/live' page_url='' acodecs=0 vcodecs=0 object_encoding=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:25 [info] 5465#0: *1 releaseStream, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:25 [info] 5465#0: *1 fcpublish, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:25 [info] 5465#0: *1 createStream, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:25 [info] 5465#0: *1 publish: name='test' args='' type=live silent=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:25 [info] 5465#0: *1 gop cache publish: name='test' type='live', client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:36 [info] 5465#0: *2 client connected '127.0.0.1'
2018/09/28 19:29:36 [info] 5465#0: *2 connect: host='localhost' app='live' args='' flashver='' swf_url='' tc_url='rtmp://localhost/live' page_url='' acodecs=3191 vcodecs=252 object_encoding=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:36 [info] 5465#0: *2 createStream, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:36 [info] 5465#0: *2 play: name='test' args='' start=0 duration=0 reset=0 silent=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:36 [info] 5465#0: *2 play: service not found: 'localhost', client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:36 [info] 5465#0: *2 disconnect, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:29:36 [info] 5465#0: *2 deleteStream, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:30:17 [info] 5465#0: *3 client connected '127.0.0.1'
2018/09/28 19:30:17 [info] 5465#0: *3 connect: host='localhost' app='live' args='' flashver='' swf_url='' tc_url='rtmp://localhost/live' page_url='' acodecs=3191 vcodecs=252 object_encoding=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:30:17 [info] 5465#0: *3 createStream, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:30:17 [info] 5465#0: *3 play: name='test' args='' start=0 duration=0 reset=0 silent=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:30:17 [info] 5465#0: *3 play: service not found: 'localhost', client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:30:17 [info] 5465#0: *3 disconnect, client: 127.0.0.1, server: 0.0.0.0:1935
2018/09/28 19:30:17 [info] 5465#0: *3 deleteStream, client: 127.0.0.1, server: 0.0.0.0:1935

Is that the correct url to play the stream if I use that config?
I also try with another server but the result is the same.

Thank in advance!

实现独立RTMP模块

  1. HTTP类(HTTP+FLV, HLS)session需要在ngx_connection_t中增加http_data (http data用ngx_http_set_ctx插入, ngx_http_get_module_ctx获取)
  2. http handler MUST return NGX_CUSTOME to avoid connection closed by http module (删除NGX_CUSTOME定义)
  3. HTTP类连接的断开需要回调HOOK (rtmp_http_close_handler回调改为ngx_http_cleanup_add方式)

解决发送GOP时丢包频繁的问题

发送缓冲大小由out_queue配置, GOP link list中包含的items通常很多, GOP越大items越多, 丢包概率越大。更改out_queue虽能解决问题, 但治标不治本, 还是得把多个items打包成一个items来发送。

按照你的那个rtmp配置文件说明不能使用

能再完善一下你的那个rtmp配置文件说明不?
其中的那个service cctv不知道是做什么用的?

我采用下面的方式发布流不成功:
ffmpeg -re -i output.flv -codec copy -f flv rtmp://127.0.0.1:1935/cctv/news/a.pub.rtmp.cctv

Fail to build on nginx 1.15

I get this error

cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../BLSS -I objs -I src/http -I src/http/modules
-o objs/addon/BLSS/ngx_rtmp_init.o
../BLSS/ngx_rtmp_init.c
../BLSS/ngx_rtmp_init.c: In function ‘ngx_http_flv_init_connection’:
../BLSS/ngx_rtmp_init.c:93:25: error: this statement may fall through [-Werror=implicit-fallthrough=]
unix_socket = 1;
~~~~~~~~~~~~^~~
../BLSS/ngx_rtmp_init.c:95:9: note: here
default: /* AF_INET /
^~~~~~~
../BLSS/ngx_rtmp_init.c:124:25: error: this statement may fall through [-Werror=implicit-fallthrough=]
unix_socket = 1;
~~~~~~~~~~~~^~~
../BLSS/ngx_rtmp_init.c:126:9: note: here
default: /
AF_INET /
^~~~~~~
../BLSS/ngx_rtmp_init.c: In function ‘ngx_rtmp_init_connection’:
../BLSS/ngx_rtmp_init.c:308:25: error: this statement may fall through [-Werror=implicit-fallthrough=]
unix_socket = 1;
~~~~~~~~~~~~^~~
../BLSS/ngx_rtmp_init.c:310:9: note: here
default: /
AF_INET /
^~~~~~~
../BLSS/ngx_rtmp_init.c:339:25: error: this statement may fall through [-Werror=implicit-fallthrough=]
unix_socket = 1;
~~~~~~~~~~~~^~~
../BLSS/ngx_rtmp_init.c:341:9: note: here
default: /
AF_INET */
^~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [objs/addon/BLSS/ngx_rtmp_init.o] Error 1
make[1]: Leaving directory `/home/ec2-user/nginx-1.15.0'
make: *** [build] Error 2

http-flv文件头问题

当直播源没有视频或者音频时,拉下来的http-flv直播流has audiohas vedio都是1,即使在推流时使用-an禁掉视频或者音频还是这样。好像是转码时没有判断吧?

http session in_pool pointer double free

daemon off;
master_process off;
error_log /dev/stdout info;
rtmp {
	timeout             60s;
	ping                60s;
	ping_timeout        30s;
	max_streams         32;
	chunk_size          4096;
	ack_window          5000000;
	max_message         10M;
	buflen              5s;
	sync                10ms;

	out_queue           2048;
	out_cork            8;
	idle_streams        off;
	interleave          on;
    server {
        listen 1936;
        service cctv {
            hostname direct-bi proto-all *.test.com;
            application cctv {
                live on;
            }
        }
    }
}
http {
    server {
        listen      8081;
        location / {
        }
    }
}
events{}

curl -v -o /dev/null "http://x.test.com:8081/cctv/unexist.flv"

访问一个不存在的flv后缀流名,会造成session的double free
blame了下似乎是个很久之前的代码?
ngx_http_flv_cleanup
-> ngx_http_flv_close_session_handler
-> ngx_rtmp_fire_event(s, NGX_RTMP_DISCONNECT, NULL, NULL);
在此之后,还会做

 368     if (s->in_pool) {
 369         ngx_destroy_pool(s->in_pool);
 370     }

RTMP pull not working

Hi,

I tried to use BLSS basically for RTMP Edge server. so I am just pulling from my origin server.
here is my configuration

"""
worker_processes 1;
relay_stream hash;

error_log logs/error.log debug;

events {
worker_connections 1024;
}

rtmp {
server {
listen 1935 reuseport;

    service cctv {
        hostname pub rtmp my_origin_server;      # match rtmp push domain
        hostname sub rtmp 52.66.143.134;
        application live {
            live on;
            gop_cache on;
            gop_cache_count 5;  # cache 5 GOPs
        }
    }
}

}
"""

I am streaming my origin server using OBS. no problem at that end.

I enabled debug mode here is errors I am getting

"""

2018/03/09 15:14:25 [debug] 14853#0: epoll: fd:4 ev:0001 d:000000000194B558
2018/03/09 15:14:25 [debug] 14853#0: *4 recv: eof:0, avail:1
2018/03/09 15:14:25 [debug] 14853#0: *4 recv: fd:4 42 of 146
2018/03/09 15:14:25 [debug] 14853#0: *4 RTMP bheader fmt=1 csid=3
2018/03/09 15:14:25 [debug] 14853#0: *4 RTMP mheader fmt=1 amf_cmd (20) time=0+0 mlen=34 len=0 msid=0
2018/03/09 15:14:25 [debug] 14853#0: *4 RTMP recv amf_cmd (20) csid=3 timestamp=0 mlen=34 msid=0 nbufs=1
2018/03/09 15:14:25 [debug] 14853#0: *4 nhandlers: 1
2018/03/09 15:14:25 [debug] 14853#0: *4 calling handler 0
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF read (1) 02 '?'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF read (2) 00 0C '??'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF read (12) 64 65 6C 65 74 65 53 74 72 65 61 6D 'deleteStream'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF func 'deletestream' passed to handler 0/1
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF read (1) 00 '?'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF read (8) 40 10 00 00 00 00 00 00 '@???????'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF read (1) 05 '?'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF read (1) 00 '?'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF read (8) 3F F0 00 00 00 00 00 00 '????????'
2018/03/09 15:14:25 [info] 14853#0: *4 deleteStream, client: 14.143.32.2, server: 0.0.0.0:1935
2018/03/09 15:14:25 [debug] 14853#0: *4 live: leave 'dryruncont'
2018/03/09 15:14:25 [debug] 14853#0: *4 live: delete empty stream 'dryruncont'
2018/03/09 15:14:25 [debug] 14853#0: *4 create: status code='NetStream.Play.Stop' level='status' desc='Stop live'
2018/03/09 15:14:25 [debug] 14853#0: *4 create: amf nelts=4
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (1) 02 '?'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (2) 00 08 '??'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (8) 6F 6E 53 74 61 74 75 73 'onStatus'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (1) 00 '?'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (8) 00 00 00 00 00 00 00 00 '????????'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (1) 05 '?'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (1) 03 '?'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (2) 00 05 '??'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (5) 6C 65 76 65 6C 'level'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (1) 02 '?'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (2) 00 06 '??'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (6) 73 74 61 74 75 73 'status'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (2) 00 04 '??'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (4) 63 6F 64 65 'code'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (1) 02 '?'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (2) 00 13 '??'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (19) 4E 65 74 53 74 72 65 61 6D 2E 50 6C 61 79 2E 53 'NetStream.Play.S'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (2) 00 0B '??'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (11) 64 65 73 63 72 69 70 74 69 6F 6E 'description'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (1) 02 '?'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (2) 00 09 '??'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (9) 53 74 6F 70 20 6C 69 76 65 'Stop live'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (2) 00 00 '??'
2018/03/09 15:14:25 [debug] 14853#0: *4 AMF write (1) 09 '?'
2018/03/09 15:14:25 [debug] 14853#0: *4 RTMP prep amf_cmd (20) fmt=0 csid=5 timestamp=0 mlen=94 msid=1 nbufs=1
2018/03/09 15:14:25 [debug] 14853#0: *4 RTMP send nmsg=1, priority=0 #8
2018/03/09 15:14:25 [debug] 14853#0: *4 send: fd:4 106 of 106
2018/03/09 15:14:25 [debug] 14853#0: *4 record: close_stream
2018/03/09 15:14:25 [debug] 14853#0: *4 recv: eof:0, avail:0
2018/03/09 15:14:25 [debug] 14853#0: timer delta: 30067
2018/03/09 15:14:25 [debug] 14853#0: worker cycle
2018/03/09 15:14:25 [debug] 14853#0: epoll timer: 29827
2018/03/09 15:14:25 [debug] 14853#0: epoll: fd:4 ev:2001 d:000000000194B558
2018/03/09 15:14:25 [debug] 14853#0: *4 recv: eof:1, avail:1
2018/03/09 15:14:25 [debug] 14853#0: *4 recv: fd:4 0 of 146
2018/03/09 15:14:25 [debug] 14853#0: *4 finalize session
2018/03/09 15:14:25 [debug] 14853#0: *4 post event 000000000193C2E8
2018/03/09 15:14:25 [debug] 14853#0: timer delta: 0
2018/03/09 15:14:25 [debug] 14853#0: posted event 000000000193C2E8
2018/03/09 15:14:25 [debug] 14853#0: *4 delete posted event 000000000193C2E8
2018/03/09 15:14:25 [debug] 14853#0: *4 close session
2018/03/09 15:14:25 [info] 14853#0: *4 disconnect, client: 14.143.32.2, server: 0.0.0.0:1935
2018/03/09 15:14:25 [info] 14853#0: *4 deleteStream, client: 14.143.32.2, server: 0.0.0.0:1935
2018/03/09 15:14:25 [debug] 14853#0: *4 live: not joined
2018/03/09 15:14:25 [debug] 14853#0: *4 record: close_stream
2018/03/09 15:14:25 [debug] 14853#0: *4 event timer del: 4: 1520608495233
2018/03/09 15:14:25 [debug] 14853#0: *4 free: 000000000191B480, unused: 3526
2018/03/09 15:14:25 [debug] 14853#0: *4 close connection
2018/03/09 15:14:25 [debug] 14853#0: *4 reusable connection: 0
2018/03/09 15:14:25 [debug] 14853#0: *4 free: 000000000193C220, unused: 128
2018/03/09 15:14:25 [debug] 14853#0: *4 free: 00000000019264D0, unused: 1617
2018/03/09 15:14:25 [debug] 14853#0: worker cycle
2018/03/09 15:14:25 [debug] 14853#0: epoll timer: -1

"""

Can you help me debug this?

I am using ubuntu 14.04

compile failed

cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g   -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/src/BLSS -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/http/v2 -I src/mail -I src/stream \
        -o objs/addon/BLSS/ngx_rtmp_variables.o \
        /usr/src/BLSS/ngx_rtmp_variables.c
/usr/src/BLSS/ngx_rtmp.c: In function 'ngx_rtmp_add_listen':
/usr/src/BLSS/ngx_rtmp.c:636:27: error: 'http2' may be used uninitialized in this function [-Werror=maybe-uninitialized]
         addr[i].opt.http2 = http2;
         ~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/src/BLSS/ngx_rtmp.c:548:28: note: 'http2' was declared here
     ngx_uint_t             http2;
                            ^~~~~
cc1: all warnings being treated as errors
make[1]: *** [objs/Makefile:1849: objs/addon/BLSS/ngx_rtmp.o] Error 1
make[1]: *** Waiting for unfinished jobs....

RTMP Pull

Hi,
I'm trying to implement an edge server with your module.
Unfortunately, I couldn't figure out how to use the pull command with your module, to pull rtmp stream from origin server.
This is the configuration I tried:
My origin server is 10.58.201.130 with nginx rtmp. Streaming to it works fine - url: rtmp://10.58.201.130/live/test2.
My edge server is the localhost. Here is my nginx config:

rtmp {
    server {
        listen 1935 reuseport;
        chunk_size 4096;                       
        allow play all;

        service cctv {
            hostname direct-bi proto-all localhost 127.0.0.1;
            application edgelive {
                live on;
                meta copy;
                pull rtmp://10.58.201.130/ app=live;
            }
            application edgelive1 {
                live on;
                meta copy;
                pull rtmp://127.0.0.1/ app=live;
            }
            application edgelive2 {
                live on;
                meta copy;
                exec_pull ffmpeg -i rtmp://10.58.201.130/live/$name -c copy -f flv rtmp://127.0.0.1/$app/$name;
            }
            application live {
                live on;

                gop_cache on;
                gop_cache_count 5;  # cache 5 GOPs

                hls on;
                hls_fragment 10s;
                hls_playlist_length 30s;
            }
      }
   }
}

With this configuration, I can play the stream from the origin server with edgelive2 application which uses exec_pull and ffmpeg.
Streaming locally into live application and using edgelive1 to play also works.
But the edgelive application does not work, ffplay show this error "RTMP_ReadPacket, failed to read RTMP packet header" when I try the url:
./ffplay rtmp://127.0.0.1/edgelive/test2
Here is the nginx log:

2018/10/03 19:49:36 [info] 7922#0: *1 client connected '127.0.0.1'
2018/10/03 19:49:36 [info] 7922#0: *1 connect: host='127.0.0.1' app='edgelive' args='' flashver='' swf_url='' tc_url='rtmp://127.0.0.1/edgelive' page_url='' acodecs=3191 vcodecs=252 object_encoding=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/10/03 19:49:36 [info] 7922#0: *1 createStream, client: 127.0.0.1, server: 0.0.0.0:1935
2018/10/03 19:49:36 [info] 7922#0: *1 play: name='test2' args='' start=0 duration=0 reset=0 silent=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/10/03 19:49:36 [info] 7922#0: *1 relay: create pull name='test2' app='live' playpath='' url='10.58.201.130/', client: 127.0.0.1, server: 0.0.0.0:1935
2018/10/03 19:49:36 [info] 7922#0: *1 gop cache play: name='test2' start=0 duration=0 reset=0, client: 127.0.0.1, server: 0.0.0.0:1935
2018/10/03 19:49:36 [info] 7922#0: *2 gop cache publish: name='test2' type='', client: 10.58.201.130/, server: ngx-relay
2018/10/03 19:50:15 [info] 7922#0: *1 disconnect, client: 127.0.0.1, server: 0.0.0.0:1935
2018/10/03 19:50:15 [info] 7922#0: *1 deleteStream, client: 127.0.0.1, server: 0.0.0.0:1935

How can I use the pull command to get the stream from a server rather than localhost? Is there any problem with the configuration?
I really appreciate any help you can provide!

Edit: Seems like adding 10.58.201.130 to hostname solves the problem.
However, It only works with standard rtmp port. When I tried to pull from a source with different port, for instance 10.58.201.130:9030, I still get the same error. How can I modify the config to pull from a specific port?

关于热更新

对于RTMP这种长连接应用层协议, nginx reload会导致大量进程常驻不被shutdown; nginx热加载逻辑不适合修改, 后续会开放用notify hook的方式来进行热加载每个session。

支持租户概念

这是我在做PaaS平台时候引入的, 通常来讲一个用户会拥有多组域名, RTMP/HTTP+FLV/HLS上下行域名各不同。

RTMP Pull and Auto relay

Hi, I am trying to use your nginx module as an edge server.

Things work fine on single worker mode. When I try the multiple workers there is a problem with it:
When a client connects and requests to play a stream, the stream is pulled from an origin server and push to other workers with ngx-local-relay. That part works as expected. But when a second client connects to another worker and requests the same stream, it also creates another pull from the origin and relays the stream to others worker.
Here is how I config nginx:
Multiple-worker

worker_processes 4;   # multi-worker process mode
relay_stream all;    # stream relay mode
relay_reconnect_time 1s;
auto_relay_socket_dir /tmp;

Edge-server - the callback return 300 with the rtmp stream url from origin

 application edgelive {
      live on;
      on_play http://host:port/v1/replay_pull;
 }

Stat from one worker:
image
Stat from another worker:
image
List tcp connection: - Origin server 10.240.152.180 - Edge 10.240.152.181 - Client 10.30.175.105
image

Is this a bug? or Do I need a different nginx config?
Any help would be greatly appreciated!

Ubuntu build failed

I am using Ubuntu 14.04 while building nginx source using BLSS module I am getting following error

../BLSS/ngx_rtmp.c: In function ‘ngx_rtmp_add_listen’:
../BLSS/ngx_rtmp.c:629:25: error: ‘ssl’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
         addr[i].opt.ssl = ssl;
                         ^
../BLSS/ngx_rtmp.c:545:28: note: ‘ssl’ was declared here
     ngx_uint_t             ssl;
                            ^
cc1: all warnings being treated as errors
make[1]: *** [objs/addon/BLSS/ngx_rtmp.o] Error 1
make[1]: Leaving directory `/root/nginx/nginx-1.12.0'
make: *** [build] Error 2

what I am doing wrong here?

Fail to build with nginx 1.13

have these error
ngx_blss_module/ngx_rtmp.c:545:28: note: 'ssl' was declared here ngx_uint_t ssl; ^ ngx_blss_module/ngx_rtmp.c:632:27: error: 'http2' may be used uninitialized in this function [-Werror=maybe-uninitialized] addr[i].opt.http2 = http2; ^ ngx_blss_module/ngx_rtmp.c:548:28: note: 'http2' was declared here ngx_uint_t http2; ^ cc1: all warnings being treated as errors cc -c -I/usr/include/luajit-2.0.4 -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -mtune=westmere -ljemalloc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -ljemalloc -march=corei7 -mtune=corei7 -DNDK_SET_VAR -Wno-deprecated-declarations -DNDK_SET_VAR -DNDK_UPSTREAM_LIST -I src/core -I src/event -I src/event/modules -I src/os/unix -I ndk/objs -I objs/addon/ndk -I lua-v0.10.0/src/api -I ngx_http_upstream_check_module -I ngx_blss_module -I openssl-1.0.2k/.openssl/include -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/http/v2 -I src/http/modules/perl -I ndk/src -I ndk/src -I ndk/objs -I objs/addon/ndk -I /usr/include/luajit-2.0.4 -I ngx_brotli/deps/brotli/include -I /usr/include/libxml2 -I src/mail -I src/stream \ -o objs/addon/ngx_blss_module/ngx_rtmp_live_module.o \ ngx_blss_module/ngx_rtmp_live_module.c make[1]: *** [objs/addon/ngx_blss_module/ngx_rtmp.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make[1]: Leaving directory /builds/portalserv/nginx/BUILD/nginx-1.13.12'
make: *** [build] Error 2`
with version of nginx need for?

Stuck at FLV header if playback start before publish

如果有任何客户端在推流之前开始播放的话,所有客户端都会卡在 FLV 头无法开始,RTMP 也不能播,但是 HLS 可以正常生成切片并播放。

edge 使用的是 pull 的方式回源。

还有一个小建议,匹配推流播放域名的功能最好可以选择关闭,或者允许使用一个 default 域名。有的时候很多域名的配置都一样,这样设置有些麻烦。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.