Difference between revisions of "Nginx: Instalasi RTMP HLS DASH"

From OnnoWiki
Jump to navigation Jump to search
Line 88: Line 88:
 
Validasi
 
Validasi
  
 +
  cd /usr/local/nginx/sbin
 
   sudo nginx -t
 
   sudo nginx -t
  
Line 93: Line 94:
 
Start NGINX
 
Start NGINX
  
 +
cd /usr/local/nginx/sbin
 
  sudo nginx
 
  sudo nginx
 
  
 
==Test dari Studio==
 
==Test dari Studio==

Revision as of 06:39, 18 May 2021

Instalasi Build Tools & Dependencies

sudo apt update
sudo apt install build-essential git libpcre3-dev libssl-dev zlib1g-dev

Compile NGINX + RTMP

sudo su
cd /usr/local/src/
git clone https://github.com/arut/nginx-rtmp-module.git
git clone https://github.com/nginx/nginx.git
cd nginx
./auto/configure --add-module=../nginx-rtmp-module
make
sudo make install

Konfigurasi

File konfigurasi di

 /usr/local/nginx/conf/nginx.conf

HLS

rtmp { 
    server { 
        listen 1935; 
        application live { 
            live on; 
            interleave on;
 
            hls on; 
            hls_path /tmp/hls; 
            hls_fragment 15s; 
        } 
    } 
} 
 
http { 
    default_type application/octet-stream;
 
    server { 
        listen 80; 
        location /tv { 
            root /tmp/hls; 
        } 
    }

    types {
        application/vnd.apple.mpegurl m3u8;
        video/mp2t ts;
        text/html html;
    } 
}


DASH

rtmp { 
    server { 
        listen 1935; 
        application live { 
            live on; 
            dash on; 
            dash_path /tmp/dash; 
            dash_fragment 15s; 
        } 
    } 
} 

http { 
    server { 
        listen 80; 
        location /tv { 
            root /tmp/dash; 
        } 
    }
 
    types {
        text/html html;
        application/dash+xml mpd;
    } 
}

Validasi Konfigurasi & Start NGINX

Validasi

 cd /usr/local/nginx/sbin
 sudo nginx -t


Start NGINX

cd /usr/local/nginx/sbin
sudo nginx

Test dari Studio

OBS di set stream ke (contoh)

rtmp://NGINX_server/tv/tv2

ffmpeg, script

ffmpeg -re -I fileyangdistream.mp4 -vcodec copy -loop -1 -c:a aac -b:a 160k -ar 44100 -strict -2 -f flv rtmp:192.168.1.138/live/bbb

Contoh URL

RTMP – rtmp://NGINX_server/live/bbb
HLS – http://NGINX_server/live/bbb.m3u8
DASH – http://NGINX_server/live/bbb.mpd