1 2 |
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev |
Make a working directory and switch to it.
1 2 3 |
mkdir ~/working cd ~/working |
1 2 3 |
wget http://nginx.org/download/nginx-1.7.5.tar.gz wget https://github.com/arut/nginx-rtmp-module/archive/master.zip |
Install the Unzip package.
1 2 |
sudo apt-get install unzip |
Extract the Nginx and Nginx-RTMP source.
1 2 3 |
tar -zxvf nginx-1.7.5.tar.gz unzip master.zip |
Switch to the Nginx directory.
1 2 |
cd nginx-1.7.5 |
Add modules that Nginx will be compiled with. Nginx-RTMP is included.
1 2 |
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master |
Compile and install Nginx with Nginx-RTMP.
1 2 3 |
make sudo make install |
Install the Nginx init scripts.
1 2 3 4 |
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 |
Start and stop Nginx to generate configuration files.
1 2 3 |
sudo service nginx start sudo service nginx stop |
Installing FFmpeg
Add the FFmpeg PPA.
1 2 |
sudo apt-add-repository ppa:jon-severinsson/ffmpeg |
Update the package lists.
1 2 |
sudo apt-get update |
Install FFmpeg.
1 2 |
sudo apt-get install ffmpeg |
Note: The apt-add-repository command may not be installed in some cases. To install it run
sudo apt-get install software-properties-common
.
Configuring Nginx-RTMP and FFmpeg
Open the Nginx configuration file.
1 2 |
sudo nano /usr/local/nginx/conf/nginx.conf |
Append the following.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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; } } } |
1 2 |
sudo service nginx restart |
1 2 |
sudo nano /usr/local/nginx/conf/nginx.conf |
Look for the following lines.
1 2 3 |
live on; record off; |
Add the following to each set of the above lines. Change 0.0.0.0 to your IP address.
1 2 3 4 |
allow publish 127.0.0.1; allow publish 0.0.0.0; deny publish all; |
The configuration should now look something like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
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; } } } |
Save the file by pressing Control and X together. Restart Nginx.
1 2 |
sudo service nginx restart |
Configuring Software to Work with Nginx-RTMP
Streaming applications typically have two fields for connection information. The first field is usually for the server information and the second field is usually for the stream name or key. The information that you should place into each field is listed. The stream name or key can be set to anything.
1 2 3 |
Field 1: rtmp://your.vultr.ip/live/ Field 2: stream-key-your-set |
To view streams open the following links in a player supporting RTMP.
1 2 3 |
rtmp://your.vultr.ip/live/stream-key-you-set rtmp://your.vultr.ip/live360p/stream-key-your-set |
Setting up a player to display live video on a website is beyond the scope of this guide. Searching for the term ‘RTMP web player’ might assist you.