Guide to Creating an RTMP Stream with OBS and Nginx

U235
3 min readJul 31, 2023

--

Introduction

Are you interested in streaming your content live to a global audience? Real-Time Messaging Protocol (RTMP) is a popular protocol for streaming live video and audio over the internet. In this article, we will walk you through the step-by-step process of setting up an RTMP stream using Open Broadcaster Software (OBS) and Nginx on your server. With this powerful combination, you’ll be able to broadcast your content to platforms like Twitch, YouTube, or any other RTMP-compatible service.

1. What is RTMP?

Before diving into the setup, let’s briefly discuss what RTMP is. RTMP is a streaming protocol developed by Adobe that enables real-time transmission of audio and video data between a client (such as OBS) and a server (like Nginx). This protocol is widely used for live streaming because of its low latency and high performance.

2. Install OBS

The first step is to download and install OBS, a free and open-source software for live streaming and screen recording. OBS is available for Windows, macOS, and Linux, making it accessible to a wide range of users. You can download OBS from the official website (https://obsproject.com/) and install it following the on-screen instructions.

3. Set Up Your Streaming Scene

After installing OBS, open the application, and you’ll be presented with the main interface. Now, you need to set up your streaming scene, which includes the sources for your video and audio.

  • Click on the “+” icon in the “Sources” box to add a source (e.g., your webcam or display capture).
  • Configure the settings for each source, such as resolution, frame rate, and audio settings.

4. Configure OBS for RTMP Streaming

Once your scene is set up, it’s time to configure OBS for RTMP streaming.

  • Go to “Settings” in the bottom-right corner of OBS.
  • Navigate to the “Stream” tab.
  • In the “Service” dropdown menu, select “Custom…”
  • In the “Server” field, enter the RTMP URL of your Nginx server. It usually looks like “rtmp://your-server-ip/app” (where “app” is the application name).
  • For the “Stream Key,” you can enter any value you like; this will be used as a unique identifier for your stream.

5. Install Nginx with the RTMP Module

Next, we’ll set up the Nginx web server with the RTMP module to handle the incoming RTMP stream from OBS.

  • Install Nginx on your server using the package manager suitable for your operating system.
  • Download the Nginx RTMP module from the GitHub repository (https://github.com/arut/nginx-rtmp-module) and follow the installation instructions provided there.

6. Configure Nginx for RTMP Streaming

Now, we need to configure Nginx to work with the RTMP module.

  • Locate the Nginx configuration file (usually located at “/etc/nginx/nginx.conf” or “/etc/nginx/sites-available/default”).
  • Edit the configuration file and add the following code inside the “http” block:
rtmp {
server {
listen 1935; # The port on which Nginx will listen for incoming RTMP streams
application app { # Replace "app" with your desired application name
live on;
# Allow the client to play the stream
allow play all;
}
}
}

Start Nginx and Stream!

Save the configuration file, and now you’re ready to start Nginx.

  • Open a terminal and start Nginx using the command: “sudo service nginx start” (or the appropriate command for your OS).
  • Back in OBS, click the “Start Streaming” button to begin broadcasting your stream to Nginx.

Conclusion

Congratulations! You have successfully set up an RTMP stream using OBS and Nginx. Now your live content can be delivered to a global audience via various streaming platforms or custom player applications. Remember to monitor your server’s performance to ensure smooth streaming, especially if you expect high viewer traffic.

Live streaming has become a powerful way to engage with your audience, whether for gaming, tutorials, or sharing memorable moments. With OBS and Nginx, you have a robust and reliable setup to make your mark in the dynamic world of live streaming. Happy streaming!

--

--

U235
U235

No responses yet