diff --git a/rtmp/nginx.conf b/rtmp/nginx.conf index 5291f84..b1784ce 100644 --- a/rtmp/nginx.conf +++ b/rtmp/nginx.conf @@ -164,9 +164,16 @@ rtmp { ## Push has the same syntax as pull. Unlike pull, push directive publishes stream to remote server. ## ## This will push the stream from incoming /live application to these below to create HLS and/or Dash streams, or to record or transcode automatically. ## ## Only enable HLS push if you are not using ABS options earlier or by using the encoder application ## - push rtmp://localhost/hls/$name_src; # Remember to enable an app called HLS! Disable it if you use transcoding using variable bitrates. - exec ffmpeg -i rtmp://localhost/src/$name - -c:a aac -b:a 64k -c:v libx264 -b:v 256k -f flv rtmp://localhost/hls/$name_mid; + #push rtmp://localhost/hls/$name_src; # Remember to enable an app called HLS! Disable it if you use transcoding using variable bitrates. + + ## TRANSCODING + exec ffmpeg -i rtmp://localhost/encoder/$name -async 1 -vsync -1 + -c:v libx264 -b:v 800k -maxrate 856k -vf "scale=640:trunc(ow/a/2)*2" -c:a aac -ar 48000 -b:a 96k -bufsize 1200k -tune zerolatency -preset veryfast -crf 23 -g 60 -hls_list_size 0 -f flv rtmp://localhost/hls/$name_360p + -c:v libx264 -b:v 1400k -maxrate 1498k -vf "scale=842:trunc(ow/a/2)*2" -c:a aac -ar 48000 -b:a 128k -bufsize 2100k -tune zerolatency -preset veryfast -crf 23 -g 60 -hls_list_size 0 -f flv rtmp://localhost/hls/$name_480p + -c:v libx264 -b:v 2800k -maxrate 2996k -vf "scale=1280:trunc(ow/a/2)*2" -c:a aac -ar 48000 -b:a 128k -bufsize 4200k -tune zerolatency -preset veryfast -crf 23 -g 60 -hls_list_size 0 -f flv rtmp://localhost/hls/$name_720p + -c:v libx264 -b:v 5000k -maxrate 5350k -vf "scale=1920:trunc(ow/a/2)*2" -c:a aac -ar 48000 -b:a 192k -bufsize 7500k -tune zerolatency -preset veryfast -crf 23 -g 60 -hls_list_size 0 -f flv rtmp://localhost/hls/$name_1080p + -c copy -f flv rtmp://localhost/hls/$name_source; + } ## YOUTUBE PUSH OPTIONS ## # push rmtp://localhost/youtube; # Uncomment this to use application on localhost (MUST BE SPECIFIED). OR simply use the following line: @@ -203,11 +210,11 @@ rtmp { ## When hls_variant suffix is matched on stream name then variant playlist is created for the current stream with all entries specified by hls_variant ## directives in current application. Stripped name without suffix is used as variant stream name. The original stream is processed as usual. ## Optional parameters following the suffix are appended to EXT-X-STREAM-INF in m3u8 playlist. See HLS spec 3.3.10. EXT-X-STREAM-INF for full list. - # hls_variant _low BANDWIDTH=288000; # _low - Low bitrate, sub-SD resolution - hls_variant _mid BANDWIDTH=448000; # _mid - Medium bitrate, SD resolution - # hls_variant _high BANDWIDTH=1152000; # _high - Higher-than-SD resolution - # hls_variant _higher BANDWIDTH=2048000; # _higher - High bitrate, HD 720p resolution - hls_variant _src BANDWIDTH=4096000; # _src - Source bitrate, source resolution + hls_variant _360p BANDWIDTH=800000 RESOLUTION=640x360; + hls_variant _480p BANDWIDTH=1400000 RESOLUTION=842x480; + hls_variant _720p BANDWIDTH=2800000 RESOLUTION=1280x720; + hls_variant _1080p BANDWIDTH=5000000 RESOLUTION=1920x1080; + hls_variant _source BANDWITH=10000000; } }