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

From OnnoWiki
Jump to navigation Jump to search
 
(11 intermediate revisions by the same user not shown)
Line 17: Line 17:
  
 
==Konfigurasi==
 
==Konfigurasi==
 +
 +
File konfigurasi di
 +
 +
  /usr/local/nginx/conf/nginx.conf
  
 
===HLS===
 
===HLS===
Line 79: Line 83:
 
     }  
 
     }  
 
  }
 
  }
 
  
 
==Validasi Konfigurasi & Start NGINX==
 
==Validasi Konfigurasi & Start NGINX==
Line 85: Line 88:
 
Validasi
 
Validasi
  
  sudo nginx -t
+
sudo su
 +
cd /usr/local/nginx/sbin
 +
./nginx -t
 +
 
 +
Harusnya keluar kira2
  
 +
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
 +
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
  
 
Start NGINX
 
Start NGINX
  
  sudo nginx
+
  sudo su
 +
cd /usr/local/nginx/sbin
 +
./nginx &
  
 +
 +
Kalau di ps ax akan keluar
 +
 +
12716 ?        Ss    0:00 nginx: master process ./nginx
 +
12717 ?        S      0:00 nginx: worker process
 +
12718 ?        S      0:00 nginx: cache manager process
  
 
==Test dari Studio==
 
==Test dari Studio==
Line 97: Line 114:
 
OBS di set stream ke (contoh)
 
OBS di set stream ke (contoh)
  
  rtmp://NGINX_server/tv/tv2
+
  rtmp://NGINX_server/live/teststream
  
 
ffmpeg, script
 
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
+
  ffmpeg -re -i fileyangdistream.mp4 -vcodec copy -loop -1 -c:a aac -b:a 160k -ar 44100 -strict -2 -f flv rtmp://192.168.0.157/live/teststream
  
 
Contoh URL
 
Contoh URL
  
  RTMP – rtmp://NGINX_server/live/bbb
+
  RTMP – rtmp://NGINX_server/live/teststream
  HLS – http://NGINX_server/live/bbb.m3u8
+
  HLS – http://NGINX_server/live/teststream.m3u8
  DASH – http://NGINX_server/live/bbb.mpd
+
  DASH – http://NGINX_server/live/teststream.mpd
 +
 
 +
==Test Client==
 +
 
 +
Test untuk menonton streaming bisa menggunakan VLC dengan alamat
 +
 
 +
RTMP – rtmp://NGINX_server/live/teststream
 +
HLS – http://NGINX_server/live/teststream.m3u8
 +
DASH – http://NGINX_server/live/teststream.mpd
 +
 
 +
==Referensi==
 +
 
 +
* https://www.nginx.com/blog/video-streaming-for-remote-learning-with-nginx/

Latest revision as of 08:32, 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

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

Harusnya keluar kira2

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

Start NGINX

sudo su
cd /usr/local/nginx/sbin
./nginx &


Kalau di ps ax akan keluar

12716 ?        Ss     0:00 nginx: master process ./nginx
12717 ?        S      0:00 nginx: worker process
12718 ?        S      0:00 nginx: cache manager process

Test dari Studio

OBS di set stream ke (contoh)

rtmp://NGINX_server/live/teststream

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.0.157/live/teststream

Contoh URL

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

Test Client

Test untuk menonton streaming bisa menggunakan VLC dengan alamat

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

Referensi