NGINX based RTMP pipeline

drone4ya z
3 min readDec 9, 2020

Drones, GoPro’s, and even $19 webcams have built-in live stream capability. They transmit video using Real-time Messaging Protocol (RTMP).

From a use-case perspective, this means the video sources can be separated from the analytics/inference module.

The first step in the process is setting up a Live video server (NGINX in our case) that will listen to a source transmitting video feed and then forward it to the destination requesting the feed (a VLC or a code running on a machine).

The flow looks like something in the diagram below:

My Setup:

Vizi-AI industrial machine vision dev kit (buy)with Ubuntu 18.04.

The key thing to note here is that these kits contain Intel® Movidius™ VPU Myriad-X, which is designed specifically to accelerate your AI workloads. For what we are trying to do here it's overkill but for what I want to achieve with this eventually it's a must.

Getting Started:

(First I want to start with due credit to the person who wrote the initial blog on how to set up NGINX-RTMP, on the Open Broadcaster Software forum (link) )

Run all the commands listed below in sequence:

  1. Install NGINX server
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-devwget http://nginx.org/download/nginx-1.15.1.tar.gzwget https://github.com/sergey-dryabzhinsky/nginx-rtmp-module/archive/dev.ziptar -zxvf nginx-1.15.1.tar.gzunzip dev.zipcd nginx-1.15.1./configure --with-http_ssl_module --add-module=../nginx-rtmp-module-devmakesudo make installsudo /usr/local/nginx/sbin/nginx

2. Let's configure the NGINX to add the RTMP module

sudo nano /usr/local/nginx/conf/nginx.conf

Add the following after the last ‘}’ you see in the config file — very important

rtmp {         
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
}
}
}

3. Restart NGINX server

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

4. Time to test

First, let's test if you can reach the NGINX server, in your browser type <IP address of NGINX server> and you should see this.

Then, we will test it with a device that can send the feed to RTMP endpoint.

In my case, it is GoPro or you can use Open Broadcaster Studio as the source.

  • GoPro instructions — see the video below
  • Use this “rtmp://< IP address of NGINX Server>/live” in GoPro as your URL

Now, open up VLC and use “rtmp://< IP address of NGINX Server>/live” to view your feed

--

--