RTMP is great for serving live content. When\u00a0RTMP<\/strong>\u00a0is paired with\u00a0FFmpeg<\/strong>, streams can be converted into various qualities. AKLWEB HOST is great for these applications as they provide fast and dedicated\u00a0CPU performance<\/strong>. AKLWEB HOST global network also ensures that you can deliver high quality live content with minimal delay. Lets get started!<\/p>\n Install the tools required to compile Nginx and Nginx-RTMP from source.<\/strong><\/p>\n Make a working directory and switch to it.<\/strong><\/p>\n Download the Nginx and Nginx-RTMP source.<\/strong><\/p>\n Install the Unzip package.<\/strong><\/p>\n Extract the Nginx and Nginx-RTMP source.<\/strong><\/p>\n Switch to the Nginx directory.<\/strong><\/p>\n Add modules that Nginx will be compiled with. Nginx-RTMP is included.<\/strong><\/p>\n Compile and install Nginx with Nginx-RTMP.<\/strong><\/p>\n Install the Nginx init scripts.<\/strong><\/p>\n Start and stop Nginx to generate configuration files.<\/strong><\/p>\n Add the FFmpeg PPA.<\/strong><\/p>\n Update the package lists.<\/strong><\/p>\n Install FFmpeg.<\/strong><\/p>\n Note: The apt-add-repository command may not be installed in some cases. To install it run\u00a0 Open the Nginx configuration file.<\/strong><\/p>\n Append the following.<\/strong><\/p>\n After you’ve added the above, you can customize settings such a video bitrate, audio bitrate and resolution. These changes will only be applied to the lower quality stream. To add more qualities, copy and paste the exec ffmpeg line and change the settings. You’ll also need to create a new application. You can do this by copying and pasting the live360 example that has been included. Don’t forget to update the exec ffmpeg line with the address of the new application. You can do this by changing the final RTMP address in the exec ffmpeg line.<\/p>\n Note:<\/strong>\u00a0Changing the value after\u00a0 Save the file by pressing Control and X together. Restart Nginx.<\/strong><\/p>\n Note: For best performance, each stream being converted should have its own CPU core.\u00a0For example two qualities, 360P and 480P are being created from a 720P stream.<\/strong>\u00a0A AKLWEB HOST instance with at least\u00a0two CPU<\/strong>\u00a0cores should be used.<\/p><\/blockquote>\n If you’re using a firewall, you’ll need to make sure\u00a0TCP 1935<\/strong>\u00a0is allowed.<\/p>\n The\u00a0current configuartion<\/strong>\u00a0allows anyone to stream to your server. We can fix this by only allowing certain IP addresses the publish permission.\u00a0Open the Nginx configuration.<\/strong><\/p>\n Look for the following lines.<\/strong><\/p>\n Add the following to each set of the above lines.<\/strong>\u00a0Change 0.0.0.0 to your\u00a0IP address<\/strong>.<\/p>\n The configuration should now look something like this.<\/strong><\/p>\n Save the file by pressing Control and X together. Restart Nginx.<\/p>\n 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.<\/p>\n To view streams open the following links in a player supporting RTMP.<\/strong><\/p>\n Setting up a player<\/strong>\u00a0to display live video on a website is beyond the scope of this guide. Searching for the term\u00a0‘RTMP web player’<\/strong>\u00a0might assist you.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[107,109,242,247],"manual_kb_tag":[134],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2148"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2148"}],"version-history":[{"count":1,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2148\/revisions"}],"predecessor-version":[{"id":2149,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2148\/revisions\/2149"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2148"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2148"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}Installing Nginx and Nginx-RTMP<\/strong><\/h3>\n
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev\r\n<\/code><\/pre>\n
mkdir ~\/working\r\ncd ~\/working\r\n<\/code><\/pre>\n
wget http:\/\/nginx.org\/download\/nginx-1.7.5.tar.gz\r\nwget https:\/\/github.com\/arut\/nginx-rtmp-module\/archive\/master.zip\r\n<\/code><\/pre>\n
sudo apt-get install unzip\r\n<\/code><\/pre>\n
tar -zxvf nginx-1.7.5.tar.gz\r\nunzip master.zip\r\n<\/code><\/pre>\n
cd nginx-1.7.5\r\n<\/code><\/pre>\n
.\/configure --with-http_ssl_module --add-module=..\/nginx-rtmp-module-master\r\n<\/code><\/pre>\n
make\r\nsudo make install\r\n<\/code><\/pre>\n
sudo wget https:\/\/raw.github.com\/JasonGiedymin\/nginx-init-ubuntu\/master\/nginx -O \/etc\/init.d\/nginx\r\nsudo chmod +x \/etc\/init.d\/nginx\r\nsudo update-rc.d nginx defaults\r\n<\/code><\/pre>\n
sudo service nginx start\r\nsudo service nginx stop\r\n<\/code><\/pre>\n
Installing FFmpeg<\/h3>\n
sudo apt-get install software-properties-common\r\nsudo add-apt-repository ppa:kirillshkrogalev\/ffmpeg-next\r\n<\/code><\/pre>\n
sudo apt-get update\r\n<\/code><\/pre>\n
sudo apt-get install ffmpeg\r\n<\/code><\/pre>\n
sudo apt-get install software-properties-common<\/code>.<\/p><\/blockquote>\n
Configuring Nginx-RTMP and FFmpeg<\/strong><\/h3>\n
sudo nano \/usr\/local\/nginx\/conf\/nginx.conf\r\n<\/code><\/pre>\n
rtmp {\r\n server {\r\n listen 1935;\r\n chunk_size 4096;\r\n\r\n application live {\r\n live on;\r\n record off;\r\n 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;\r\n }\r\n application live360p {\r\n live on;\r\n record off;\r\n }\r\n }\r\n}\r\n<\/code><\/pre>\n
-b:v<\/code>\u00a0will change the video bitrate. This is measured in kilobits per second. Changing the value after\u00a0
-b:a<\/code>\u00a0will change the audio bitrate. This is measured in kilobits per second. Changing the value after\u00a0
-s<\/code>\u00a0will change the resolution.<\/p><\/blockquote>\n
sudo service nginx restart\r\n<\/code><\/pre>\n
Security Note<\/strong><\/h3>\n
sudo nano \/usr\/local\/nginx\/conf\/nginx.conf\r\n<\/code><\/pre>\n
live on;\r\n record off;\r\n<\/code><\/pre>\n
allow publish 127.0.0.1;\r\n allow publish 0.0.0.0;\r\n deny publish all;\r\n<\/code><\/pre>\n
rtmp {\r\n server {\r\n listen 1935;\r\n chunk_size 4096;\r\n\r\n application live {\r\n live on;\r\n record off;\r\n allow publish 127.0.0.1;\r\n allow publish 0.0.0.0;\r\n deny publish all;\r\n 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;\r\n }\r\n application live360p {\r\n live on;\r\n record off;\r\n allow publish 127.0.0.1;\r\n allow publish 0.0.0.0;\r\n deny publish all;\r\n }\r\n }\r\n}\r\n<\/code><\/pre>\n
sudo service nginx restart\r\n<\/code><\/pre>\n
Configuring Software to Work with Nginx-RTMP<\/strong><\/h3>\n
Field 1: rtmp:\/\/your.akl-web-host.ip\/live\/\r\nField 2: stream-key-you-set\r\n<\/code><\/pre>\n
rtmp:\/\/your.akl-web-host.ip\/live\/stream-key-you-set\r\nrtmp:\/\/your.akl-web-host.ip\/live360p\/stream-key-you-set\r\n<\/code><\/pre>\n