NGINX with RTMP on Raspberry Pi as a streaming server for OBS

Published by Tobias Hofmann on

3 min read

Some time passed since I last wrote about OBS. In 2014, I started using OBS as a streaming solution for an event in Sao Paulo. I had quite some time to convince the co-organizers that streaming to an app and YouTube at the same time is a good idea, and that OBS is a good software for achieving this. In the end, my idea was accepted and SITSP video was captured with OBS and streamed through NGINX to YouTube. I even managed to provide live streaming to iPhone devices via an event app I wrote! OBS was not a very well-known software in 2014, and today it is like the de-facto standard for YouTubers when it comes to streaming game videos. 5+ years later and my architecture is still valid and an example of good solution architecture (and another proof of my visionary skills).

End of 2019 I decided to record videos: capture content of a computer with OBS and stream it to NGINX and recapture it with OBS or watch it with VLC. As my 2014 architecture is still valid, I decided to use my old solution architecture, review it and update it where necessary.

NGINX installation

Debian has a package for NGINX and RTMP. My Raspberry Pi is using the armv7l architecture (uname -m), and for that architecture, the RTMP module is available for Debian buster. If you are not on buster, consider upgrading Raspbian. It’s easier to install software via apt than having to compile it manually.

sudo apt-get update
sudo apt-get install libnginx-mod-rtmp

NGINX configuration

During the installation, NGINX will be started. This fails in my case, as I already have a web server (Apache) running. The port 80 is already used and NGINX startup fails. This is OK, as I do not want NGINX as a web server, just for RTMP and OBS.

To solve this “problem”, I’ll change NGINX configuration and deactivate the HTTP server listening on port 80. The NGINX configuration is located in directory /etc/nginx/.

  • The master configuration file is nginx.conf, where the http connector is configured.
  • The actual server is located in /etc/nginx/sites-enabled/default. Here the local server is configured to listen on port 80.

Deleting this symlink in sites-enabled will deactivate the localhost server and NGINX will start, as it now no longer tries to start a server on port 80 (that is already in use by Apache).

sudo rm sites-enabled/default
sudo systemctl start nginx.service
sudo systemctl status nginx.service

Status so far: NGINX is installed and running. Next task is to enable RTMP.

Enable RTMP

Create file rtmp.conf in /etc/nginx/. In this file will contain the RTMP server configuration. The configuration will make RTMP listen on port 1935 and expose a RTMP URL named live. This is the URL RTMP clients will connect to.

sudo vim rtmp.conf

Add content.

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

Enable RTMP configuration in NGINX. Change nginx.conf to load the above created rtmp.conf file. Add the following line at the top of the file to load the above created rtmp.conf file.

include /etc/nginx/rtmp.conf;

Start NGINX with RTMP

sudo systemctl stop nginx.service
sudo systemctl start nginx.service
sudo systemctl status nginx.service

This should restart NGINX and show no errors. To see if NGINX is now listening on port 1935 for RTMP, you can use netstat.

netstat -an | grep 1935

OBS configuration

After performing all the above tasks, NGINX with RTMP is up and running. Now you can connect OBS to it.

Server: rtmp://
Key: test

Start streaming in OBS. To see if it works, start VLC and connect to rtmp:// The content OBS captures and streams should now be shown in VLC. There is a lag of a few seconds. This is normal, as the content is buffered.

Let the world know

Tobias Hofmann

Doing stuff with SAP since 1998. Open, web, UX, cloud. I am not a Basis guy, but very knowledgeable about Basis stuff, as it's the foundation of everything I do (DevOps). Performance is king, and unit tests is something I actually do. Developing HTML5 apps when HTML5 wasn't around. HCP/SCP user since 2012, NetWeaver since 2002, ABAP since 1998.


Donald Reynolds · April 1, 2020 at 04:42

I’m having troubles getting NGINX running with RTMP… In the process above do I need to install NGINX separately in advance? I didn’t and I expect that the steps above install a complete version of NGINX that is RTMP enabled. Is that correct?

    Tobias Hofmann · April 1, 2020 at 12:49

    The command “apt-get install libnginx-mod-rtmp” installs nginx with rtmp enabled. The output shows the additionals files selected (e.g. nginx-common, nginx-full).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.