nginx: create rtmp streaming server
This commit is contained in:
parent
12d95c1808
commit
24a9343a20
@ -96,6 +96,7 @@ in
|
||||
allowedTCPPorts = [
|
||||
111 2049 4000 4001 4002 # NFS
|
||||
3483 9000 9090 # Slimserver
|
||||
1935 # RTMP
|
||||
];
|
||||
allowedUDPPorts = [
|
||||
111 2049 4000 4001 4002 # NFS
|
||||
|
@ -77,6 +77,9 @@ in
|
||||
services = {
|
||||
nginx = {
|
||||
enable = true;
|
||||
package = pkgs.nginx.override {
|
||||
modules = with pkgs.nginxModules; [ rtmp ];
|
||||
};
|
||||
recommendedGzipSettings = true;
|
||||
recommendedOptimisation = true;
|
||||
recommendedProxySettings = true;
|
||||
@ -188,6 +191,18 @@ in
|
||||
root = "/run/python-ci/nyanloutre/site-max";
|
||||
};
|
||||
};
|
||||
"stream.nyanlout.re" = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
root = "/var/www/hls/";
|
||||
|
||||
locations."/" = {
|
||||
extraConfig = ''
|
||||
add_header Cache-Control no-cache;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
'';
|
||||
};
|
||||
};
|
||||
"login.nyanlout.re" = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
@ -209,6 +224,35 @@ in
|
||||
"ci.nyanlout.re" = nginxSimpleReverse 52350;
|
||||
"gitea.nyanlout.re" = nginxSimpleReverse config.services.gitea.httpPort;
|
||||
};
|
||||
appendConfig = ''
|
||||
rtmp {
|
||||
server {
|
||||
listen 1935;
|
||||
|
||||
application live {
|
||||
live on;
|
||||
|
||||
exec_push ${pkgs.ffmpeg}/bin/ffmpeg -i rtmp://localhost/$app/$name -async 1 -vsync -1
|
||||
-c:v libx264 -c:a aac -b:v 768k -b:a 96k -vf "scale=720:trunc(ow/a/2)*2" -tune zerolatency -preset ultrafast -crf 28 -f flv rtmp://localhost/show/$name_mid
|
||||
-c:v libx264 -c:a aac -b:v 1024k -b:a 128k -vf "scale=960:trunc(ow/a/2)*2" -tune zerolatency -preset ultrafast -crf 28 -f flv rtmp://localhost/show/$name_high
|
||||
-c copy -f flv rtmp://localhost/show/$name_src 2>>${config.services.nginx.virtualHosts."stream.nyanlout.re".root}/ffmpeg-$name.log;
|
||||
}
|
||||
|
||||
application show {
|
||||
live on;
|
||||
hls on;
|
||||
|
||||
hls_path ${config.services.nginx.virtualHosts."stream.nyanlout.re".root};
|
||||
hls_fragment 3s;
|
||||
hls_playlist_length 60s;
|
||||
|
||||
hls_variant _mid BANDWIDTH=448000; # Medium bitrate, SD resolution
|
||||
hls_variant _high BANDWIDTH=1152000; # High bitrate, higher-than-SD resolution
|
||||
hls_variant _src BANDWIDTH=4096000; # Source bitrate, source resolution
|
||||
}
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
postgresql.enable = true;
|
||||
|
Loading…
Reference in New Issue
Block a user