Welcome to World of IPTV

Join us now to get access to all our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, and so, so much more. It's also quick and totally free, so what are you waiting for?

Forum Rules

Our Rules: Read to avoid getting banned!

Advertising

Introduce Yourself to the World with Us!

Resource Database

Find the newest resources around IPTV!

Account upgrade

Upgrade your account to unlock more benefits!

Tutorial Setup Nginx 1.7.8 + RTMP + FFmpeg on Ubuntu 14.04

redhat

Administrator
Staff member
Administrator
Joined
Jun 19, 2019
Messages
3,298
Reaction score
15,884
Points
134
Location
root[@]woi
RTMP is great for serving live content. When RTMP is paired with FFmpeg, streams can be converted into various qualities. Streaming-Servers.com is great for these applications as they provide fast and dedicated CPU performance. Streaming-Servers.com global network also ensures that you can deliver high quality live content with minimal delay.

Lets get started!

1. Connect with putty to your Server with preinstalled Ubuntu 14.04.x LTS 64 Bit

2. Enter following commands in your Shell (exclude the lines with #)

Bash:
apt-get install build-essential libpcre3 libpcre3-dev libssl-dev unzip software-properties-common
mkdir /usr/build

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

#Extract the Nginx and Nginx-RTMP source.
tar -zxvf nginx-1.7.8.tar.gz
unzip master.zip

#Switch to the Nginx directory.
cd nginx-1.7.8

#Add modules that Nginx will be compiled with. Nginx-RTMP is included.
./configure --with-http_ssl_module --with-http_stub_status_module --with-http_secure_link_module --with-http_flv_module --with-http_mp4_module --add-module=../nginx-rtmp-module-master

#Compile and install Nginx with Nginx-RTMP
make
make install

#Install the Nginx init scripts.
wget https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx
chmod +x /etc/init.d/nginx
update-rc.d nginx defaults

#Start and stop Nginx to generate configuration files.
service nginx start
service nginx stop

#Add the FFmpeg PPA and Installing FFmpeg
apt-add-repository ppa:jon-severinsson/ffmpeg
apt-get update
apt-get install ffmpeg


3. Once the installation is, lets configure Nginx-RTMP and FFmpeg

Open the Nginx configuration file.
Bash:
nano /usr/local/nginx/conf/nginx.conf

Append the following
Bash:
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 1200K -s 720x576 -f flv -c:a aac -ac 1 -strict -2 -b:a 128k rtmp://localhost/live720p/$name;
            }
            application live720p {
                    live on;
                    record off;
        }
    }
}

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 live720 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.

Note: Changing the value after -b:v will change the video bitrate. This is measured in kilobits per second. Changing the value after -b:a will change the audio bitrate. This is measured in kilobits per second. Changing the value after -s will change the resolution.

Save the file by pressing Control and X together. Restart Nginx.
Bash:
service nginx restart

Note: For best performance, each stream being converted should have its own CPU core. For example two qualities, 360P and 480P are being created from a 720P stream. A Streaming-Servers.com instance with at least two CPU cores should be used.

Security Note
If you're using a firewall, you'll need to make sure TCP 1935 is allowed.

The current configuartion allows anyone to stream to your server. We can fix this by only allowing certain IP addresses the publish permission. Open the Nginx configuration.
Bash:
nano /usr/local/nginx/conf/nginx.conf

Look for the following lines
Bash:
                live on;
                record off;

Add the following to each set of the above lines. Change 0.0.0.0 to your IP address.
Bash:
                allow publish 127.0.0.1;
                allow publish 0.0.0.0;
                deny publish all;

The configuration should now look something like this
Bash:
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 1200K -s 720x576 -f flv -c:a aac -ac 1 -strict -2 -b:a 128k rtmp://localhost/live720p/$name;
            }
            application live720p {
                    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.
Bash:
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.
Bash:
Field 1: rtmp://your.server.ip/live/
Field 2: stream-key-you-set

To view streams open the following links in a player (for example VLC Player) supporting RTMP.
Bash:
rtmp://your.server.ip/live/stream-key-you-set
rtmp://your.server.ip/live720p/stream-key-you-set

Setting up a player to display live video on a website is beyond the scope of this guide.
 
Last edited:
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 @changcdn
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 @changcdn
1000 cnx / 500€ 20Gbps / 700€ 40CPU-128GRAM 20Gbps / €980 http://coronaserver.com
@redhat this does not work...

when you have to add the repository for ffmpeg it gives this error:
Cannot add PPA: 'ppa:jon-severinsson/ffmpeg'.
Please check that the PPA name or format is correct.

If you can let me know how to move forward with this is would be grateful! :)
 
@redhat this does not work...

when you have to add the repository for ffmpeg it gives this error:
Cannot add PPA: 'ppa:jon-severinsson/ffmpeg'.
Please check that the PPA name or format is correct.

If you can let me know how to move forward with this is would be grateful! :)

Try this:
Bash:
sudo add-apt-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg

or

Bash:
sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get install ffmpeg
 
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 @changcdn
1000 cnx / 500€ 20Gbps / 700€ 40CPU-128GRAM 20Gbps / €980 http://coronaserver.com
@XOPORTO
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Reading package lists... Done
W: Ignoring Provides line with DepCompareOp for package libavcodec58
W: Ignoring Provides line with DepCompareOp for package libavfilter7
W: Ignoring Provides line with DepCompareOp for package libavcodec58
W: Ignoring Provides line with DepCompareOp for package libavfilter7
W: You may want to run apt-get update to correct these problems


root@sd-105942:~/nginx-1.7.8# sudo apt-get install ffmpeg
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
ffmpeg : Depends: libavdevice58 (= 7:4.1.3-0york1~14.04) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.



Any ideas how to sort them problems? seems like its now compatible with 14.04 ?
 
sudo apt-get install libav-tools
and then
sudo apt-get install ffmpeg



this sorted it :)
 
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 @changcdn
1000 cnx / 500€ 20Gbps / 700€ 40CPU-128GRAM 20Gbps / €980 http://coronaserver.com
Anyone know what code i need to change to get xc1.6 to see the video? All i get is sound


libx264 dont seem to work
 
Last edited:
ok tried everything to get this to work but it only streams sound, not video...

Is there any way around this? @redhat
 
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 @changcdn
1000 cnx / 500€ 20Gbps / 700€ 40CPU-128GRAM 20Gbps / €980 http://coronaserver.com
thanks for sharing is very clearly
 
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 @changcdn
1000 cnx / 500€ 20Gbps / 700€ 40CPU-128GRAM 20Gbps / €980 http://coronaserver.com
@redhat this does not work...

when you have to add the repository for ffmpeg it gives this error:
Cannot add PPA: 'ppa:jon-severinsson/ffmpeg'.
Please check that the PPA name or format is correct.

If you can let me know how to move forward with this is would be grateful! :)
I'm too. i have solved

- apt-get install libav-tools

and after write this

- apt-add-repository ppa:jon-severinsson/ffmpeg
- apt-get update
- apt-get install ffmpeg
 
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;
}
}
}
 
shape1
shape2
shape3
shape4
shape5
shape6
Back
Top