0% found this document useful (0 votes)
23 views4 pages

Streaming Via RTMP Using Nginx

This document describes how to set up a streaming server using the RTMP protocol with the Nginx web server on Ubuntu. It explains the steps to download and install Nginx and the RTMP module, compile the source code, configure the service to listen on port 1935, and test video streaming to a player via an RTMP URL.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views4 pages

Streaming Via RTMP Using Nginx

This document describes how to set up a streaming server using the RTMP protocol with the Nginx web server on Ubuntu. It explains the steps to download and install Nginx and the RTMP module, compile the source code, configure the service to listen on port 1935, and test video streaming to a player via an RTMP URL.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Practice: Creation of a server of

streaming using the RTMP protocol


about Ubuntu, using the web server
Nginx.

The Real-Time Messaging Protocol (RTMP) was developed by Macromedia as a


method for transferring data, audio, and video for its own Flash technology. Macromedia was
subsequently acquired by Adobe, and from that moment on the protocol specification
it has been partially made available to other manufacturers. This has brought with it that the
RTMP protocol technology is used by a large number of manufacturers, being one of
the most widely used streaming protocols today.

On the other hand, Nginx (pronounced in English 'engine X') is a lightweight web server/reverse proxy.
high performance and a proxy for email protocols (IMAP/POP3).
It is free software and open source, licensed under the simplified BSD License; it also exists
a commercial version distributed under the name of nginx plus. It is cross-platform, so it runs
on Unix-like systems (GNU/Linux, BSD, Solaris, Mac OS X, etc.) and Windows.
Nginx is used for a long list of sites web known,
such as: WordPress, Netflix, Hulu, GitHub, Ohloh, SourceForge, TorrentReactor and parts of Facebook
(like the server for downloading heavy zip files). The following graph shows the high
percentage of use of this web server worldwide on the internet (January 2018):

In this practice we will set up a media server using the Nginx web server with
RTMP on Ubuntu Linux.

Preparation, compilation and installation of Nginx and the module


RTMP for Nginx
Nginx-RTMP is an additional module of the Nginx web server that is used for streaming.
multimedia streams (streaming) of both video and audio, using the RTMP protocol. This
the module does not come pre-packaged to be installed by the operating system, which means
that we will have to compile Nginx from its source code. To do this we will write in the
Ubuntu machine the following command line:

sudo apt-get install build-essential libpcre3 libpcre3-dev


libssl-dev unzip

This will take some time. With this line we install the necessary tools to be able to carry out the
compilation of the source code and the creation of the corresponding packages.

The next step is to obtain the source code of Nginx. In this practice, we will use version
1.8.1. For more recent versions, the procedure is similar.

1
Then we will do:

create directory nginx

cd nginx

wget[Link]

tar -zxvf [Link]

Now we will need the source code for the Nginx-RTMP module, which we will download.
with the following orders:

wget [Link]
module/archive/[Link]

unzip [Link]

At this point, we will have a directory called nginx-1.8.1 that contains the source code.
from Nginx, and another directory called nginx-rtmp-module-master that contains the code
source of the Nginx-RTMP module. The next step is to reconfigure the source code of Nginx
to be compiled together with the Nginx-RTMP module, by means of:

cd nginx-1.8.1

./configure --with-http_ssl_module --add-module=../nginx-rtmp-


module-master

When executing the command, a certain amount of text will scroll on the screen. Once it finishes,
the compilation and installation of Nginx is carried out with these two command lines:

make

sudo make install

At this point, Nginx will be installed in the folder /usr/local/nginx. To check


the operation, we activate the Nginx web service:

sudo /usr/local/nginx/sbin/nginx

If the installation has been successful, the Nginx test page can be accessed if we use
a web browser and we connect to the IP of the Ubuntu server where we have done the
installation.

To stop Nginx, the command to stop the service is:

sudo /usr/local/nginx/sbin/nginx -s stop

2
Service configuration.
The next step is to write the necessary lines in the [Link] file to configure the
RTMP module, which we will open with the text editor of our choice, in this case nano:

sudo nano /usr/local/nginx/conf/[Link]

We go to the end of the file and copy the following lines, finally saving the
file once we have copied them:

rtmp {

server {

listen 1935;

chunk_size 8192;

application vod {

play /usr/local/nginx/rtmp;

With the lines written, what we have established in the configuration is that Nginx listens to the
streaming requests for port 1935, which is the default port for the protocol
RTMP.

We have also established the size of the audio or video transmission packets to
8192 bits each, which is a suitable standard size.

Later we created an 'application' called vod for video on demand


There can be as many "applications" as wanted, each with a name.
different.

As the directory where the video files to be transmitted are located, we have specified the
Folder /usr/local/nginx/rtmp This folder does not exist, so it needs to be created and the ...
video files corresponding, which can only have the .mp4 formats
.flv, which are the only formats served by the Nginx-RTMP module:

sudo mkdir /usr/local/nginx/rtmp

The following is to restart the Nginx service, so that it acquires the configuration that
we have changed:

sudo /usr/local/nginx/sbin/nginx

3
Test.
To test the operation, we run the VLC media player and select the
Open network location, by entering the URL of the video to stream using
streaming.

The URL will start with rtmp:// to inform VLC which streaming protocol to use,
followed by the domain name or IP address of the Ubuntu server, then the name of the
"application" and finally the name of the video file to be transmitted. For example:

rtmp://ipdelservidor/vod/test.mp4

rtmp://ipdelservidor/vod/[Link]

You might also like