Difference between revisions of "Nginx: Instalasi RTMP HLS DASH"
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
Onnowpurbo (talk | contribs)  | 
				Onnowpurbo (talk | contribs)   | 
				||
| Line 118: | Line 118: | ||
ffmpeg, script  | ffmpeg, script  | ||
| − |   ffmpeg -re -  | + |   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/  | + |   RTMP – rtmp://NGINX_server/live/teststream  | 
| − |   HLS – http://NGINX_server/live/  | + |   HLS – http://NGINX_server/live/teststream.m3u8  | 
| − |   DASH – http://NGINX_server/live/  | + |   DASH – http://NGINX_server/live/teststream.mpd  | 
==Referensi==  | ==Referensi==  | ||
* https://www.nginx.com/blog/video-streaming-for-remote-learning-with-nginx/  | * https://www.nginx.com/blog/video-streaming-for-remote-learning-with-nginx/  | ||
Revision as of 08:05, 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/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.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