2020-11-12 11:41:52 +01:00
|
|
|
rtmp_auto_push on;
|
|
|
|
rtmp_auto_push_reconnect 1s;
|
|
|
|
|
|
|
|
rtmp {
|
|
|
|
server {
|
2020-11-12 15:05:24 +01:00
|
|
|
#listen 1935;
|
|
|
|
listen [::]:1935;
|
2020-11-12 11:41:52 +01:00
|
|
|
chunk_size 4096;
|
|
|
|
|
|
|
|
application stream {
|
|
|
|
live on;
|
|
|
|
record off;
|
|
|
|
|
|
|
|
allow publish all;
|
|
|
|
#deny publish all;
|
|
|
|
allow play 127.0.0.1;
|
|
|
|
|
2020-11-12 15:05:24 +01:00
|
|
|
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;
|
2020-11-12 11:41:52 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
application stream-data {
|
|
|
|
live on;
|
|
|
|
|
|
|
|
allow publish all;
|
|
|
|
#deny publish all;
|
|
|
|
allow play 127.0.0.1;
|
|
|
|
|
2020-11-12 15:05:24 +01:00
|
|
|
on_publish http://127.0.0.1:{{ osp_worker_start_port }}/auth-user;
|
2020-11-12 11:41:52 +01:00
|
|
|
push rtmp://127.0.0.1:1935/live/;
|
|
|
|
push rtmp://127.0.0.1:1935/record/;
|
|
|
|
|
|
|
|
hls on;
|
|
|
|
hls_path {{ osp_http_path }}/live;
|
|
|
|
hls_fragment 1;
|
|
|
|
hls_playlist_length 30s;
|
|
|
|
|
|
|
|
hls_nested on;
|
|
|
|
hls_fragment_naming system;
|
|
|
|
|
|
|
|
recorder thumbnail {
|
|
|
|
record video;
|
|
|
|
record_max_frames 600;
|
|
|
|
record_path {{ osp_http_path }}/stream-thumb;
|
|
|
|
record_interval 120s;
|
|
|
|
|
|
|
|
exec_record_done ffmpeg -ss 00:00:01 -i $path -vcodec png -vframes 1 -an -f rawvideo -s 384x216 -y {{ osp_http_path }}/stream-thumb/$name.png;
|
|
|
|
exec_record_done ffmpeg -ss 00:00:00 -t 3 -i $path -filter_complex "[0:v] fps=30,scale=w=384:h=-1,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1" -y {{ osp_http_path }}/stream-thumb/$name.gif;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
application stream-data-adapt {
|
|
|
|
live on;
|
|
|
|
|
|
|
|
allow publish all;
|
|
|
|
#deny publish all;
|
|
|
|
allow play 127.0.0.1;
|
|
|
|
|
2020-11-12 15:05:24 +01:00
|
|
|
on_publish http://127.0.0.1:{{ osp_worker_start_port }}/auth-user;
|
2020-11-12 11:41:52 +01:00
|
|
|
push rtmp://127.0.0.1:1935/live/;
|
|
|
|
push rtmp://127.0.0.1:1935/record/;
|
|
|
|
|
|
|
|
exec ffmpeg -i rtmp://127.0.0.1:1935/live/$name
|
|
|
|
-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 16 -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 16 -f flv rtmp://localhost:1935/show/$name_480
|
|
|
|
-c copy -f flv rtmp://localhost:1935/show/$name_src;
|
|
|
|
|
|
|
|
|
|
|
|
recorder thumbnail {
|
|
|
|
record video;
|
|
|
|
record_max_frames 600;
|
|
|
|
record_path {{ osp_http_path }}/stream-thumb;
|
|
|
|
record_interval 120s;
|
|
|
|
|
|
|
|
exec_record_done ffmpeg -ss 00:00:01 -i $path -vcodec png -vframes 1 -an -f rawvideo -s 384x216 -y {{ osp_http_path }}/stream-thumb/$name.png;
|
|
|
|
exec_record_done ffmpeg -ss 00:00:00 -t 3 -i $path -filter_complex "[0:v] fps=30,scale=w=384:h=-1,split [a][b];[a] palettegen=stats_mode=single [p];[b][p] paletteuse=new=1" -y {{ osp_http_path }}/stream-thumb/$name.gif;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
application show {
|
|
|
|
live on;
|
|
|
|
allow publish 127.0.0.1;
|
|
|
|
allow play 127.0.0.1;
|
|
|
|
|
|
|
|
hls on;
|
|
|
|
hls_path {{ osp_http_path }}/live-adapt;
|
|
|
|
hls_nested on;
|
|
|
|
hls_fragment 1;
|
|
|
|
hls_playlist_length 30s;
|
|
|
|
|
|
|
|
hls_fragment_naming system;
|
|
|
|
|
|
|
|
record off;
|
|
|
|
|
|
|
|
# Instruct clients to adjust resolution according to bandwidth
|
|
|
|
hls_variant _480 BANDWIDTH=1200000; # Medium bitrate, SD resolution
|
|
|
|
hls_variant _720 BANDWIDTH=2048000; # High bitrate, HD 720p resolution
|
|
|
|
hls_variant _src BANDWIDTH=4096000; # Source bitrate, source resolution
|
|
|
|
}
|
|
|
|
|
|
|
|
application record {
|
|
|
|
live on;
|
|
|
|
|
|
|
|
allow publish 127.0.0.1;
|
|
|
|
allow play 127.0.0.1;
|
|
|
|
|
2020-11-12 15:05:24 +01:00
|
|
|
on_publish http://127.0.0.1:{{ osp_worker_start_port }}/auth-record;
|
2020-11-12 11:41:52 +01:00
|
|
|
exec_push mkdir -m 764 {{ osp_http_path }}/videos/$name;
|
|
|
|
|
|
|
|
recorder all {
|
|
|
|
record all;
|
|
|
|
record_path /tmp;
|
|
|
|
record_unique on;
|
|
|
|
record_suffix _%Y%m%d_%H%M%S.flv;
|
|
|
|
exec_record_done bash -c "ffmpeg -y -i $path -codec copy -movflags +faststart {{ osp_http_path }}/videos/$name/$basename.mp4 && rm $path";
|
|
|
|
exec_record_done mv {{ osp_http_path }}/stream-thumb/$name.png {{ osp_http_path }}/videos/$name/$basename.png;
|
|
|
|
exec_record_done mv {{ osp_http_path }}/stream-thumb/$name.gif {{ osp_http_path }}/videos/$name/$basename.gif;
|
2020-11-12 15:05:24 +01:00
|
|
|
on_record_done http://127.0.0.1:{{ osp_worker_start_port }}/deauth-record;
|
2020-11-12 11:41:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
application live {
|
|
|
|
live on;
|
|
|
|
drop_idle_publisher 30s;
|
|
|
|
allow publish 127.0.0.1;
|
|
|
|
allow play all;
|
|
|
|
|
2020-11-12 15:05:24 +01:00
|
|
|
on_play http://127.0.0.1:{{ osp_worker_start_port }}/playbackAuth;
|
2020-11-12 11:41:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|