Welcome to World of IPTV

With

+23k members
+11k threads
+106k posts

we are the most popular IPTV community on the web. 

IMPORTANT NOTE:
WE HAVE RECENTLY NOTICED THAT TOO MANY DOUBLE FAKE ACCOUNTS ARE CREATED IN THE PAST.
TO PREVENT THIS ISSUE THE DECISION WAS MADE THAT IN THE FUTURE A ANNUALLY FEE 20 EURO WILL BE RAISED FOR NEW MEMBERSHIPS.

Join now to the World of IPTV

Forum Rules

Before you start, check out the forum rules first

Account upgrade

Upgrade your account to get access to full features

Advertising

Would you like to place your advertisement with us ?

Resources Manager

Hundreds of IPTV scripts and apps are available for download

Tutorial How To Install Nginx RTMP Server + HLS on Ubuntu 16.04 | EASY!

redhat

Administrator
Staff member
Administrator
Chief Moderator
Moderator
Joined
Jun 19, 2019
Messages
3,074
Reaction score
14,825
Points
134
Location
root[@]woi
nginx-ffmpeg.png

How To Install Nginx RTMP Server + HLS on Ubuntu 16.04 | EASY!


Install the tools required to compile Nginx and Nginx-RTMP from source.
Bash:
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev


Download the Nginx and Nginx-RTMP source.
Bash:
wget http://nginx.org/download/nginx-1.14.0.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip


Install the Unzip package.
Bash:
sudo apt-get install unzip


Extract the Nginx and Nginx-RTMP source.
Bash:
tar -zxvf nginx-1.14.0.tar.gz
unzip master.zip


Switch to the Nginx directory.
Bash:
cd nginx-1.14.0


Add modules that Nginx will be compiled with. Nginx-RTMP is included.
Apache config:
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master


Compile and install Nginx with Nginx-RTMP.
Apache config:
make
sudo make install


Now Install the Nginx init scripts.
Bash:
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


Update the package lists.
Bash:
sudo apt-get update


Install FFmpeg.
Bash:
sudo apt-get install ffmpeg


Create the folder structures necessary to hold the live and mobile HLS manifests and video fragments:
Bash:
sudo mkdir /HLS
sudo mkdir /HLS/live
sudo mkdir /HLS/mobile
sudo mkdir /video_recordings
sudo chmod -R 777 /video_recordings


It’s probably a good idea to have your firewall turned on if you haven’t done so already. If so, you must allow traffic into the ports used by Nginx and HLS. If you’d like to run without the firewall for now, ignore the ufw section below.
Bash:
sudo ufw limit ssh
sudo ufw allow 80
sudo ufw allow 1935
sudo ufw enable


Now open the nginx configuration file
Bash:
sudo nano /usr/local/nginx/conf/nginx.conf


Remove the code and open this file and add this code to it
Bash:
#user nobody;
worker_processes  1;

error_log  logs/rtmp_error.log debug;
pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    server {
        listen       80;
        server_name  localhost;

        location /hls {
            # Serve HLS fragments

            # CORS setup
            add_header 'Access-Control-Allow-Origin' '*' always;
            add_header 'Access-Control-Expose-Headers' 'Content-Length';

            # allow CORS preflight requests
            if ($request_method = 'OPTIONS') {
                add_header 'Access-Control-Allow-Origin' '*';
                add_header 'Access-Control-Max-Age' 1728000;
                add_header 'Content-Type' 'text/plain charset=UTF-8';
                add_header 'Content-Length' 0;
                return 204;
            }


            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            root /tmp;
            add_header Cache-Control no-cache;
        }
    }
}

rtmp {
        server {
                listen 1935;
                chunk_size 8192;

                application hls {
                        live on;
                        meta copy;
                        hls on;
                        hls_path /tmp/hls;
        }
    }
}
Ctrl + X to save the file to disk and exit.

Before you do anything else, it’s important to take care of what is called “cross-domain” restrictions, which would otherwise shut down your ability to stream to a webpage/website. Create a crossdomain.xml file in your nginx/html folder and put instructions in it to allow data to flow between domains:
Bash:
sudo nano /usr/local/nginx/html/crossdomain.xml

First copy (from this page) and then paste (right-click) into the nano editor field the following XML data:
Bash:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
Press Ctrl + O to write out, then Ctrl + X to save the file to disk and exit.
And your done!

little info about your servers
FMS URL: rtmp://your-ip/hls/

Stream Key: ANY thing you like, I usually set it to stream.

again if you set your stream key to movie then it would look something like this
 
Last edited:

sakpasay

Extended Member
Ext. Member
Joined
Aug 31, 2019
Messages
64
Reaction score
370
Points
64
Location
USA
This is great!
I finally got it right. Perfect instruction on how to install NGINX.
Just like the title said ... EASY to install. I tried to install it on my Server many times a few months back .could not get it done.
Flussonnic I'm half way there my friend, another good software to do restreams I'll be gone with my $80 a month which I can hardly afford.(lol)
Thank you WORLDOFIPTV ...
 
Channels MatchTime Unblock CDN Offshore Server Contact
100 cnx / 90€ 5Gbps / 180€ 48CPU-256GRAM 10Gbps 569€ Skype live:giefsl
500 cnx / 350€ 10Gbps / 350€ 48CPU-128GRAM 5Gbps / 349€ TG @changglobize
1000 cnx / 500€ 20Gbps / 700€ 40CPU-128GRAM 20Gbps / €980 http://coronaserver.com
Channels MatchTime Unblock CDN Offshore Server Contact
100 cnx / 90€ 5Gbps / 180€ 48CPU-256GRAM 10Gbps 569€ Skype live:giefsl
500 cnx / 350€ 10Gbps / 350€ 48CPU-128GRAM 5Gbps / 349€ TG @changglobize
1000 cnx / 500€ 20Gbps / 700€ 40CPU-128GRAM 20Gbps / €980 http://coronaserver.com
Channels MatchTime Unblock CDN Offshore Server Contact
100 cnx / 90€ 5Gbps / 180€ 48CPU-256GRAM 10Gbps 569€ Skype live:giefsl
500 cnx / 350€ 10Gbps / 350€ 48CPU-128GRAM 5Gbps / 349€ TG @changglobize
1000 cnx / 500€ 20Gbps / 700€ 40CPU-128GRAM 20Gbps / €980 http://coronaserver.com

teco_baba

Extended Member
Ext. Member
Joined
Oct 8, 2019
Messages
28
Reaction score
71
Points
29
Location
turkey
thanks, I tested good working but hls stream 1 minutes behind from orginal stream. how to set hls stream 10-15 seconds behind orginal stream, How to build low latency time nginx for hls stream
 
Last edited:

wilton1994

Basic Member
Basic Member
Banned
Joined
Oct 12, 2019
Messages
38
Reaction score
132
Points
44
Location
wilton9956
Hi, good job, do you have any tutorials that can explain how to add streams? Thanks.
 
Channels MatchTime Unblock CDN Offshore Server Contact
100 cnx / 90€ 5Gbps / 180€ 48CPU-256GRAM 10Gbps 569€ Skype live:giefsl
500 cnx / 350€ 10Gbps / 350€ 48CPU-128GRAM 5Gbps / 349€ TG @changglobize
1000 cnx / 500€ 20Gbps / 700€ 40CPU-128GRAM 20Gbps / €980 http://coronaserver.com

bojep

Basic Member
Basic Member
Banned
Joined
Oct 2, 2019
Messages
287
Reaction score
785
Points
101
Location
morocco
nginx-ffmpeg.png

How To Install Nginx RTMP Server + HLS on Ubuntu 16.04 | EASY!


Install the tools required to compile Nginx and Nginx-RTMP from source.
Bash:
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev


Download the Nginx and Nginx-RTMP source.
Bash:
wget http://nginx.org/download/nginx-1.14.0.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip


Install the Unzip package.
Bash:
sudo apt-get install unzip


Extract the Nginx and Nginx-RTMP source.
Bash:
tar -zxvf nginx-1.14.0.tar.gz
unzip master.zip


Switch to the Nginx directory.
Bash:
cd nginx-1.14.0


Add modules that Nginx will be compiled with. Nginx-RTMP is included.
Apache config:
./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-master


Compile and install Nginx with Nginx-RTMP.
Apache config:
make
sudo make install


Now Install the Nginx init scripts.
Bash:
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


Update the package lists.
Bash:
sudo apt-get update


Install FFmpeg.
Bash:
sudo apt-get install ffmpeg


Create the folder structures necessary to hold the live and mobile HLS manifests and video fragments:
Bash:
sudo mkdir /HLS
sudo mkdir /HLS/live
sudo mkdir /HLS/mobile
sudo mkdir /video_recordings
sudo chmod -R 777 /video_recordings


It’s probably a good idea to have your firewall turned on if you haven’t done so already. If so, you must allow traffic into the ports used by Nginx and HLS. If you’d like to run without the firewall for now, ignore the ufw section below.
Bash:
sudo ufw limit ssh
sudo ufw allow 80
sudo ufw allow 1935
sudo ufw enable


Now open the nginx configuration file
Bash:
sudo nano /usr/local/nginx/conf/nginx.conf


Remove the code and open this file and add this code to it
Bash:
#user nobody;
worker_processes  1;

error_log  logs/rtmp_error.log debug;
pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    server {
        listen       80;
        server_name  localhost;

        location /hls {
            # Serve HLS fragments

            # CORS setup
            add_header 'Access-Control-Allow-Origin' '*' always;
            add_header 'Access-Control-Expose-Headers' 'Content-Length';

            # allow CORS preflight requests
            if ($request_method = 'OPTIONS') {
                add_header 'Access-Control-Allow-Origin' '*';
                add_header 'Access-Control-Max-Age' 1728000;
                add_header 'Content-Type' 'text/plain charset=UTF-8';
                add_header 'Content-Length' 0;
                return 204;
            }


            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            root /tmp;
            add_header Cache-Control no-cache;
        }
    }
}

rtmp {
        server {
                listen 1935;
                chunk_size 8192;

                application hls {
                        live on;
                        meta copy;
                        hls on;
                        hls_path /tmp/hls;
        }
    }
}
Ctrl + X to save the file to disk and exit.

Before you do anything else, it’s important to take care of what is called “cross-domain” restrictions, which would otherwise shut down your ability to stream to a webpage/website. Create a crossdomain.xml file in your nginx/html folder and put instructions in it to allow data to flow between domains:
Bash:
sudo nano /usr/local/nginx/html/crossdomain.xml

First copy (from this page) and then paste (right-click) into the nano editor field the following XML data:
Bash:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
Press Ctrl + O to write out, then Ctrl + X to save the file to disk and exit.
And your done!

little info about your servers
FMS URL: rtmp://your-ip/hls/

Stream Key: ANY thing you like, I usually set it to stream.

again if you set your stream key to movie then it would look something like this
verry verry thanks bro
 
Channels MatchTime Unblock CDN Offshore Server Contact
100 cnx / 90€ 5Gbps / 180€ 48CPU-256GRAM 10Gbps 569€ Skype live:giefsl
500 cnx / 350€ 10Gbps / 350€ 48CPU-128GRAM 5Gbps / 349€ TG @changglobize
1000 cnx / 500€ 20Gbps / 700€ 40CPU-128GRAM 20Gbps / €980 http://coronaserver.com

Delete

Extended Member
Ext. Member
Joined
Nov 28, 2019
Messages
1
Reaction score
0
Points
1
Location
DPR
Tell me how can I add a regular stream here, which goes through http// ???
 

tyblbs

Extended Member
Ext. Member
Joined
Sep 4, 2019
Messages
96
Reaction score
151
Points
54
Location
algeria
when i have added this ffmpeg order in ubuntu, the broadcast start succefully.

input : iptv (.ts - m3u8)
output : rtmp:// (youtube-...)

root@ssdz:~# exec ffmpeg -i http://**iptv**.ts -threads 1 -c:v libx264 -profile:v baseline -b:v 1200K$ 1200K -s 720x576 -f flv -c:a aac -ac 1 -strict -2 -b:a 128k rtmp://output;



and when i add this order ffmpeg in nginx and i restart nginx .
the broadcast don't start .

rtmp {
server {
listen 1935;
chunk_size 4096;

application live {
live on;
record off;
allow publish 127.0.0.1;
allow publish 138.201.145.138;
deny publish all;
exec ffmpeg -i http://**iptv**.ts -threads 1 -c:v libx264 -profile:v baseline -b:v 1200K$ 1200K -s 720x576 -f flv -c:a aac -ac 1 -strict -2 -b:a 128k rtmp://output;
}
application live720p {
live on;
record off;
allow publish 127.0.0.1;
allow publish 138.201.145.138;
}
}
}
 
Channels MatchTime Unblock CDN Offshore Server Contact
100 cnx / 90€ 5Gbps / 180€ 48CPU-256GRAM 10Gbps 569€ Skype live:giefsl
500 cnx / 350€ 10Gbps / 350€ 48CPU-128GRAM 5Gbps / 349€ TG @changglobize
1000 cnx / 500€ 20Gbps / 700€ 40CPU-128GRAM 20Gbps / €980 http://coronaserver.com

kingkong

Extended Member
Ext. Member
Joined
Feb 3, 2020
Messages
10
Reaction score
101
Points
24
Location
SE
Clear instructions ! Well done
 
shape1
shape2
shape3
shape4
shape5
shape6
Top
AdBlock Detected

We know, ad-blocking software do a great job at blocking ads. But our site is sponsored by advertising. 

For the best possible site experience please take a moment to disable your AdBlocker.
You can create a Account with us or if you already have account, you can prefer an Account Upgrade.

I've Disabled AdBlock