improve nginx rtmp routing (ffmpeg direct on ingress + $name on push

This commit is contained in:
Geno 2020-12-09 10:52:21 +01:00
parent fec0c029d3
commit 787b91246d
1 changed files with 25 additions and 9 deletions

View File

@ -13,7 +13,9 @@ rtmp {
allow publish all;
#deny publish all;
allow play ::1;
allow play 127.0.0.1;
deny play all;
on_publish http://127.0.0.1:{{ osp_worker_start_port }}/auth-key;
on_publish_done http://127.0.0.1:{{ osp_worker_start_port }}/deauth-user;
@ -24,11 +26,13 @@ rtmp {
allow publish all;
#deny publish all;
allow play ::1;
allow play 127.0.0.1;
deny play all;
on_publish http://127.0.0.1:{{ osp_worker_start_port }}/auth-user;
push rtmp://127.0.0.1:1935/live/;
push rtmp://127.0.0.1:1935/record/;
push rtmp://127.0.0.1:1935/live/$name;
push rtmp://127.0.0.1:1935/record/$name;
hls on;
hls_path {{ osp_http_path }}/live;
@ -54,17 +58,19 @@ rtmp {
allow publish all;
#deny publish all;
allow play ::1;
allow play 127.0.0.1;
deny play all;
on_publish http://127.0.0.1:{{ osp_worker_start_port }}/auth-user;
push rtmp://127.0.0.1:1935/live/;
push rtmp://127.0.0.1:1935/record/;
push rtmp://127.0.0.1:1935/live/$name;
push rtmp://127.0.0.1:1935/record/$name;
exec ffmpeg -i rtmp://127.0.0.1:1935/live/$name
-c:v libx264 -c:a aac -b:a 192k -vf "scale=-2:1080" -vsync 1 -copyts -start_at_zero -sws_flags lanczos -r 30 -g 30 -keyint_min 30 -force_key_frames "expr:gte(t,n_forced*1)" -tune zerolatency -preset ultrafast -crf 28 -maxrate 4192k -bufsize 8384k -threads 4 -f flv rtmp://localhost:1935/show/$name_1080
-c:v libx264 -c:a aac -b:a 128k -vf "scale=-2:720" -vsync 1 -copyts -start_at_zero -sws_flags lanczos -r 30 -g 30 -keyint_min 30 -force_key_frames "expr:gte(t,n_forced*1)" -tune zerolatency -preset ultrafast -crf 28 -maxrate 2096k -bufsize 4192k -threads 4 -f flv rtmp://localhost:1935/show/$name_720
-c:v libx264 -c:a aac -b:a 96k -vf "scale=-2:480" -vsync 1 -copyts -start_at_zero -sws_flags lanczos -r 30 -g 30 -keyint_min 30 -force_key_frames "expr:gte(t,n_forced*1)" -tune zerolatency -preset ultrafast -crf 28 -maxrate 1200k -bufsize 2400k -threads 4 -f flv rtmp://localhost:1935/show/$name_480;
# -c copy -f flv rtmp://localhost:1935/show/$name_src;
exec ffmpeg -i rtmp://127.0.0.1:1935/stream-data-adapt/$name
-c:v libx264 -c:a aac -b:a 192k -vf "scale=-2:1080" -vsync 1 -copyts -start_at_zero -sws_flags lanczos -r 30 -g 30 -keyint_min 30 -force_key_frames "expr:gte(t,n_forced*1)" -tune zerolatency -preset ultrafast -crf 28 -maxrate 4192k -bufsize 8384k -threads 4 -f flv rtmp://127.0.0.1:1935/show/$name_1080
-c:v libx264 -c:a aac -b:a 128k -vf "scale=-2:720" -vsync 1 -copyts -start_at_zero -sws_flags lanczos -r 30 -g 30 -keyint_min 30 -force_key_frames "expr:gte(t,n_forced*1)" -tune zerolatency -preset ultrafast -crf 28 -maxrate 2096k -bufsize 4192k -threads 4 -f flv rtmp://127.0.0.1:1935/show/$name_720
-c:v libx264 -c:a aac -b:a 96k -vf "scale=-2:480" -vsync 1 -copyts -start_at_zero -sws_flags lanczos -r 30 -g 30 -keyint_min 30 -force_key_frames "expr:gte(t,n_forced*1)" -tune zerolatency -preset ultrafast -crf 28 -maxrate 1200k -bufsize 2400k -threads 4 -f flv rtmp://127.0.0.1:1935/show/$name_480;
# -c copy -f flv rtmp://127.0.0.1:1935/show/$name_src;
recorder thumbnail {
@ -81,8 +87,12 @@ rtmp {
application show {
live on;
allow publish ::1;
allow publish 127.0.0.1;
deny publish all;
allow play ::1;
allow play 127.0.0.1;
deny play all;
hls on;
hls_path {{ osp_http_path }}/live-adapt;
@ -104,8 +114,12 @@ rtmp {
application record {
live on;
allow publish ::1;
allow publish 127.0.0.1;
deny publish all;
allow play ::1;
allow play 127.0.0.1;
deny play all;
on_publish http://127.0.0.1:{{ osp_worker_start_port }}/auth-record;
exec_push mkdir -m 764 {{ osp_http_path }}/videos/$name;
@ -125,7 +139,9 @@ rtmp {
application live {
live on;
drop_idle_publisher 30s;
allow publish ::1;
allow publish 127.0.0.1;
deny publish all;
allow play all;
on_play http://127.0.0.1:{{ osp_worker_start_port }}/playbackAuth;