sneaky4oe icon

Setup UBUNTU NGINX 2019.06 (sneakyjoe.ru config)

sneaky4oe | PRO | 12/18/20 07:26:14 PM UTC (Edited) | 0 ⭐ | 4170 👁️ | Never ⏰ | []
Bash |

9.06 KB

|

None

|

0 👍

/

0 👎

# This is nginx setup of sneakyjoe.ru
# Based on obs forums and helping squad articles.
# Made for personal use and sharing with the crowd.
# Updated with new tweaks for the best job each time I learn something new.
 
# WARNING! Streaming WILL drop all the fucking time if you stream to server higher than 1920x1080/60
 
# WARNING! This will 100% work only on UBUNTU 16.04 with HWE Kernel enabled on installation.
 
 
LOCALE change file set to "LANG=en_EN.UTF-8"
 
/etc/default/locale
 
________________________________________________________________________
 
SETUP IP AND DNS:
 
sudo mcedit /etc/network/interfaces
 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
 
source /etc/network/interfaces.d/*
 
# The loopback network interface
auto lo
iface lo inet loopback
 
# The primary network interface
auto enp35s0
iface enp35s0 inet static
address 192.168.0.55
netmask 255.255.255.0
gateway 192.168.0.1
 
dns-nameservers 208.67.222.222 8.8.8.8
_______________________________________________________________________
 
FFMPEG install 
 
sudo wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
sudo wget http://sneakyjoe.ru/go/ffmpeg-release4.1.3-amd64-static.tar.xz
sudo tar -xJf ffmpeg-release-amd64-static.tar.xz 
sudo mkdir /usr/bin/ffmpeg-dir
sudo mv -v ~/ffmpeg-4.1.3-amd64-static/* /usr/bin/ffmpeg-dir
sudo ln -s /usr/bin/ffmpeg-dir/ffmpeg /usr/bin/ffmpeg
______________________________________________________________________
 
NGINX install:
 
sudo mkdir nginx
cd nginx
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev
sudo wget http://nginx.org/download/nginx-1.13.8.tar.gz
sudo wget https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/archive/dev.zip
sudo tar -zxvf nginx-1.13.8.tar.gz
sudo apt-get install unzip
sudo unzip dev.zip
cd nginx-1.13.8
sudo ./configure --with-http_ssl_module --without-http_gzip_module --add-module=../nginx-rtmp-module-dev
sudo make
sudo make install
sudo /usr/local/nginx/sbin/nginx
 
______________________________________________________________________
 
CONFIGURE template:
 
sudo mcedit /usr/local/nginx/conf/nginx.conf
sudo /usr/local/nginx/sbin/nginx -s stop
sudo /usr/local/nginx/sbin/nginx
 
______________________________________________________________________
 
AUTOSTART with diagnostics:
 
sudo mcedit /etc/rc.local
 
exec 2> /tmp/rc.local.log  # send stderr from rc.local to a log file
exec 1>&2                  # send stdout to the same log file
set -x                     # tell sh to display commands before execution
 
sleep 5s
 
# sudo ethtool -s enp35s0 speed 1000 ## This is for gigabit networks to enable higher speeds
 
/usr/local/nginx/sbin/nginx
 
______________________________________________________________________
 
If cant stream to youtube because of IPv6 error add 3 lines to the end of file:
 
sudo mcedit /etc/sysctl.conf
 
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
 
______________________________________________________________________
 
RESTART template:
 
sudo /usr/local/nginx/sbin/nginx -s stop
sudo /usr/local/nginx/sbin/nginx
 
______________________________________________________________________
 
VODCAST template:
 
# Streams files from such template adding a text over my webcam position. File formats my custom %Y.%m.%d___%H-%M___1080.flv and OBS no spaces:
# 2018.12.31___23-59___1080.flv     for 1080p files
# 2018-02-06 03-31-46.mkv           for 1440p files
# Requires a read-access for file /home/sneakyjoe/RECS/font/consolas.ttf
filename=$1
extension=${filename:26:3}
echo $extension
if [ "$extension" = "flv" ]; then
        fdate=${filename:0:10}
        ftime=${filename:13:5}
        vodtime="$fdate $ftime"
        echo $vodtime
        sudo ffmpeg -re -i ~/RECS/$1 -b:v 6000k -minrate 5500k -maxrate 6500k -bufsize 7000k -vcodec libx264 -preset faster -s 1920x1080 -sws_flags bicubic -r 60 -x264-params nal-hrd=cbr:force-cfr=1:keyint=120 -vf drawtext="fontfile=/home/sneakyjoe/RECS/font/consolas.ttf:text='Запись от $vodtime':fontcolor=white:fontsize=12:box=1:[email protected]:boxborderw=5:x=(w-text_w)-150:y=(h-text_h)-10" -acodec aac -ab 160k -f flv rtmp://localhost/vodcaster/
else
        fdate1=${filename:0:4}
        fdate2=${filename:5:2}
        fdate3=${filename:8:2}
        ftime=${filename:11:5}
        vodtime="$fdate1.$fdate2.$fdate3 $ftime"
        echo $vodtime
        sudo ffmpeg -re -i ~/RECS/$1 -ss 00:00:03 -b:v 6000k -minrate 5500k -maxrate 6500k -bufsize 7000k -vcodec libx264 -preset faster -s 1920x1080 -sws_flags bicubic -r 60 -x264-params nal-hrd=cbr:force-cfr=1:keyint=120 -vf drawtext="fontfile=/home/sneakyjoe/RECS/font/consolas.ttf:text='Запись от $vodtime':fontcolor=white:fontsize=33:box=1:[email protected]:boxborderw=5:x=(w-text_w)-380:y=(h-text_h)-20" -acodec aac -ab 160k -map 0:v:0 -map 0:a:5 -strict -2 -f flv rtmp://localhost/vodcaster/
fi
 
______________________________________________________________________
 
Stream to receiver application.
NGINX template: 
 
rtmp {
    server {
        listen 1935;
        chunk_size 4000; # max size 16777215
 
                    ## Uncomment in case of frequent disconnections
                    ## PacKoMMEHTuPyu ECJlu O6C 4ACTO OTKJll04AETC9\
                    # ping 1m;
                    # ping_timeout 10s;
                    # drop_idle_publisher 10s;
 
            application receiver
                {
                    live on;
                    meta copy;
                    
                    # This sends stream to transcoder
                    push rtmp://127.0.0.1/transcoder/;
 
                    # Add source streams here you don't want to transcode
 
                    # Twitch source
                #     push rtmp://live-fra.twitch.tv/app/************************;
 
                    # Youtube source
                #     push rtmp://b.rtmp.youtube.com:1935/live2/************************;
                }
 
 
            application transcoder
                {
                    live on;
                    meta copy;
 
                # 1080 all sites
                    exec ffmpeg -i rtmp://127.0.0.1/transcoder/
 
                    -b:v 6000k
                    -minrate 5500k
                    -maxrate 6500k
                    -bufsize 7000k
 
                    -vcodec libx264
                    -preset faster
                    -s 1920x1080
                    -sws_flags bicubic
 
                  #  -vf unsharp=3:3:1.5 # Video sharpening
 
                    -r 60
                    -x264-params nal-hrd=cbr:force-cfr=1:keyint=120
 
                    -acodec aac
                    -ab 160k
                  #  -strict -2
 
                    -f flv rtmp://127.0.0.1/transcoded-1080/
 
                  #  -loglevel verbose
                  #  2>>/home/sneakyjoe/ffmpeg-log.txt
                    ;
 
                # 560 periscope
                  #  exec ffmpeg -i rtmp://127.0.0.1/transcoder/
 
                  #  -b:v 740k
                  #  -minrate 600k
                  #  -maxrate 800k
                  #  -bufsize 800k
 
                  #  -vcodec libx264
                  #  -preset fast
                  #  -s 960x540
                  #  -sws_flags lanczos
 
                  #  -r 30
                  #  -x264-params nal-hrd=cbr:force-cfr=1:keyint=60
 
                  #  -acodec aac
                  #  -ab 90k
                  #  -strict -2
 
                  #  -f flv rtmp://127.0.0.1/transcoded-560/;
                }
 
 
            application transcoded-1080
                {
                    live on;
                    meta copy;
 
                    # Twitch transcoded
               #     push rtmp://live-fra.twitch.tv/app/************************;
 
                    # youtube transcoded
               #     push rtmp://b.rtmp.youtube.com:1935/live2/************************;
 
                    # Restream.io transcoded
               #     push rtmp://eu-east.restream.io/live/************************;
 
                    # dailymotion transcoded
               #     push rtmp://publish.dailymotion.com/publish-dm/************************;
 
                    # Cybergame transcoded
               #     push rtmp://premium.cybergame.tv:1953/************************;
 
                    # GoodGame transcoded
               #     push rtmp://msk.goodgame.ru:1940/live/************************;
 
                    # Mixer (beam.pro) transcoded
               #     push rtmp://ingest-fra.mixer.com:1935/beam/************************;
 
                   ## This block will save your transcoded stream to record_path. Remember to create ~/RECS and do "chmod 777 ~/RECS"
                   # recorder myrec
                   #       {
                   #           record all;
                   #           record_path /home/sneakyjoe/RECS;                    #Change sneakyjoe with your username
                   #           record_suffix _%Y.%m.%d___%H-%M___1080.flv;
                   #       }
 
            }
    }
}

Comments