Setup Nginx-RTMP pada Ubuntu 14.04

RTMP menyediakan live content untuk media streaming. mari kita cuba pasang nginx dan nginx-RMP. ikuti langkah dibawah

Install tool untuk compile Nginx dan Nginx-RTMP

sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev
buat folder bernama working 

mkdir ~/working
cd ~/working
 download Nginx dan Nginx_RTMP
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip

install dan unzip
sudo apt-get install unzip 

kemudian extrak Nginx dan Nginx-RTMP
unzip master.zip
Masuk kedalam folder nginx 
cd nginx-1.7.5
tambah module Nginx akan kompile dengan nginx RTMP
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master
 Compile dan install Nginx bersama Nginx_RTMP
make
sudo make install

Install skrip init Nginx 
sudo wget https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx
sudo chmod +x /etc/init.d/nginx
sudo update-rc.d nginx defaults
restart web server
sudo service nginx start
sudo service nginx stop

Install FFmpeg
tambah FFmpeg PPA

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
update pakage
sudo apt-get update

Install FFmpeg

sudo apt-get install ffmpeg
[tambah arahan repository jika tidak install ]sudo apt-get install software-properties-common
Configure Nginx-RTMP dan FFmpeg
sudo nano /usr/local/nginx/conf/nginx.conf
rtmp {
    server {
            listen 1935;
            chunk_size 4096;

            application live {
                    live on;
                    record off;
                    exec ffmpeg -i rtmp://localhost/live/$name -threads 1 -c:v libx264 -profile:v baseline -b:v 350K -s 640x360 -f flv -c:a aac -ac 1 -strict -2 -b:a 56k rtmp://localhost/live360p/$name;
            }
            application live360p {
                    live on;
                    record off;
        }
    }
}
sudo service nginx restart
Security : tukar port ke 1935
 TCP 1935
sudo nano /usr/local/nginx/conf/nginx.conf
Edit line berikut :
 live on;
 record off;
tambah 0.0.0.0
allow publish 127.0.0.1;
allow publish 0.0.0.0;
deny publish all;

rtmp {
    server {
            listen 1935;
            chunk_size 4096;

            application live {
                    live on;
                    record off;
                    allow publish 127.0.0.1;
                    allow publish 0.0.0.0;
                    deny publish all;
                    exec ffmpeg -i rtmp://localhost/live/$name -threads 1 -c:v libx264 -profile:v baseline -b:v 350K -s 640x360 -f flv -c:a aac -ac 1 -strict -2 -b:a 56k rtmp://localhost/live360p/$name;
            }
            application live360p {
                    live on;
                    record off;
                    allow publish 127.0.0.1;
                    allow publish 0.0.0.0;
                    deny publish all;
        }
    }
}
sudo service nginx restart


Field 1: rtmp://your.vultr.ip/live/
Field 2: stream-key-you-set

view stream 

rtmp://your.vultr.ip/live/stream-key-you-set
rtmp://your.vultr.ip/live360p/stream-key-you-set

Comments