Learn how to set up libnginx-mod-rtmp on Ubuntu for stable, high-quality live streaming with complete configuration and FFmpeg integration. Our Live Support team is always here to help you.

Reliable Live Streaming with libnginx-mod-rtmp on Ubuntu

Live streaming can be tricky, especially when your broadcasts crash unexpectedly. However, using libnginx-mod-rtmp on your Linux server can turn things around. This open-source NGINX module transforms your server into a robust RTMP server, making live video streaming reliable and free. Below, you’ll find a complete, hands-on guide to set up your RTMP server, configure your firewall, and start streaming using FFmpeg.

libnginx-mod-rtmp

Preparing Your Server

Before diving in, ensure your server meets the minimum requirements. For this tutorial, Ubuntu 20.04 LTS is used, but other Linux distributions will work as well. You’ll need:

  • NGINX installed on your server.
  • A non-root user with sudo privileges.
  • At least 2 CPU cores, 2 GB RAM, and 20 GB of disk space.

These resources are enough for testing and small-scale live streams. For larger audiences, scale up accordingly.

Installing libnginx-mod-rtmp

First, update your package database to get the latest versions:

sudo apt update -y

Next, install the libnginx-mod-rtmp module:

sudo apt install libnginx-mod-rtmp -y

This module enables NGINX to communicate with Adobe Flash player and handle live video streaming efficiently.

Configuring the RTMP Server

After installation, open the NGINX configuration file to enable live streaming:

sudo nano /etc/nginx/nginx.conf

Then, add the following code to configure your server:

rtmp {
server {
listen 1935;
chunk_size 4096;
allow publish 127.0.0.1;
deny publish all;
application live {
live on;
record off;
}
}
}

This setup tells NGINX to act as an RTMP server on port 1935, allows only localhost to publish, and disables recording by default.

Securing Your Server with a Firewall

Next, secure the network traffic with UFW, Ubuntu’s default firewall. Allow traffic on port 1935 for RTMP:

sudo ufw allow 1935/tcp
sudo ufw disable && sudo ufw enable
sudo ufw status

This ensures your RTMP server is reachable while maintaining control over incoming connections.

Streaming Video Using FFmpeg

Finally, test your server with FFmpeg. Start by installing required libraries:

sudo apt install -y libpcre3 libpcre3-dev libssl-dev zlib1g-dev
sudo apt install ffmpeg -y

Use the following command to stream a video file:

ffmpeg -re -i "video.mp4" -c:v copy -c:a aac -ar 44100 -ac 1 -f flv rtmp://139.180.203.6:1935/live/streamname.flv

This command reads your video at the original frame rate, keeps the video format unchanged, encodes audio in AAC, sets the sample rate to 44100 Hz, converts audio to mono, and streams it to your configured RTMP application. Replace video.mp4 and streamname.flv with your own file and stream name.

[If needed, Our team is available 24/7 for additional assistance.]

Conclusion

With libnginx-mod-rtmp, setting up a reliable live stream on Ubuntu is straightforward. By following this configuration and firewall setup, you can host your own live broadcasts without relying on expensive third-party platforms. Integrating FFmpeg makes testing and streaming videos simple, giving you full control over your content delivery.

libnginx-mod-rtmp is free, lightweight, and efficient, making it an excellent choice for anyone looking to run live streams directly from their server. Transitioning from test streams to larger audiences only requires scaling your server resources and maintaining the same setup.