RTMP: Receive video on linux

To receive videostream from the drone (here: Mavic Mini), you need 3 things.

  1. a server application, that can receive rtmp (here: nginx)
  2. a viewer (here: vlc)
  3. the right configuration.

Ok, let’s start with the server. I am using debian/bullseye 64-bit, but should run on Ubuntu or other linux distros, too. Even on Raspberry pie.

  1. Ok, on your linux system you need to install nginx and a plugin for nginx, to enable rtmp.
    command as root:

apt-get update && apt-get install nginx libnginx-mod-rtmp vlc

  1. Edit /etc/nginx/nginx.conf and add these lines at the bottom of this file:
rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application live {
                        live on;
                        record off;
                }
        }
}

The port with the listen command 1935 can be chosen free to any other free port. I chose 1935 because it is the same port, youtube is using.

  1. Start or restart nginx:

/etc/init.d/nginx start

  1. To check, if rtmp is listening, you can use a portscanner like nmap:

nmap -sT localhost

Looks this way:

Starting Nmap 7.80 ( https://nmap.org ) at 2022-02-07 18:48 CET
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00032s latency).
Not shown: 985 closed ports
PORT STATE SERVICE
22/tcp open ssh


1935/tcp open rtmp

24800/tcp open unknown

Nmap done: 1 IP address (1 host up) scanned in 0.20 seconds

  1. Start VLC and start network stream. The syntax is like this:

rtmp://192.168.178.102:1935/live

Explanation: The first is the protocol (rtmp://), then the ip-address where vlc is running (here mine is 192.168.178.102), then followed by a colon the port (:1935) and last followed by a slash the word live (/live).

(The word live must be added, but here I am stuck, why. I believe, it is the name of a temporary file, that is created. You can choose any other, but “live” worked)

  1. Well, now in Litchi go to RTMP and add the line as above, too:

rtmp://192.168.178.102:1935/live

  1. After some seconds you will see the video in VLC!

Notes: I noted, that the video is fluently on my notebook, but there is a almost 3-5 second delay compared to the video in the mobile phone. Note, that I am running 2,4GHz on my router, my notebook is old (2x2,2GHz, 4GB RAM, connection with wlan). Newer and faster network connections might be faster on the computer.

Second note: I saw some desciptions of linux and windows, using OBS Studio (a free and open source video software). Sadly I managed not to get video in there, and it is not clear for me, why it is used at all. However, maybe it is necessary in Windows (who cares of Windows!), but I did not need it in Linux.

Still testing other software, as VLC is consuming much process power, it is not the best choice for this one (although the easiest). SMPLAYER is a much smoother software and need very few ressources. However, still I was not able to get network stream running in smplayer.

For the windows users: There are some good tutorials in youtube related to RTMP + drone. As thwere are not much, I do not post the link. There are only 5 or 6, they should be easily found.

And as I do not use windows since decades, this tutorial aimed to linux users.

Have fun!

Best

Hans

There is one thing, that is a little bit annoying, but I suppose, the developers will change it:

Whenever the rtmp-stream is stopped in Litchi, you have to reenter the full url in the menu. Litchi does not keep the latest entry, or what would be better, the last 5 (or so) entries.

If those were kept, this would make things more comfortable.

Just a little hint…

Best regards

Hans

Should be fixed in 4.21.2 beta

1 Like