How to make a Streaming Server with OBS and Ubuntu?
Streaming has become an essential part of content creation, whether for gaming, online courses, or live events. Open Broadcaster Software (OBS) is a widely used open-source tool for high-quality streaming. This guide will walk you through setting up a streaming server using OBS on Ubuntu, along with important optimizations for a stable stream.
Prerequisites
Before you begin, ensure you have:
- A server running Ubuntu 20.04 or later with at least:
- 2 vCPUs
- 4GB RAM
- Stable internet connection
- OBS installed on your local machine (Windows/Linux/Mac) or directly on the Ubuntu server
- Basic knowledge of Linux commands
- An RTMP server for hosting your stream (Nginx RTMP or an external service like YouTube or Twitch)
Step 1: Install OBS on Ubuntu
OBS requires certain dependencies before installation. Run the following commands:
sudo apt update && sudo apt upgrade -y sudo apt install ffmpeg v4l2loopback-dkms
To install OBS:
sudo add-apt-repository ppa:obsproject/obs-studio sudo apt update sudo apt install obs-studio
Step 2: Setting Up an RTMP Server on Ubuntu
Instead of streaming directly to platforms like YouTube, you can set up your own RTMP server for private broadcasting.
Install Nginx with RTMP Module
sudo apt install nginx libnginx-mod-rtmp -y
Configure RTMP
Edit the Nginx configuration file:
sudo nano /etc/nginx/nginx.conf
Add the following lines at the end:
rtmp { server { listen 1935; chunk_size 4096; application live { live on; record off; } } }
Save and exit (CTRL+X
, then Y
, then Enter
). Restart Nginx:
sudo systemctl restart nginx
Your RTMP server is now ready at rtmp://your-server-ip/live
.
Step 3: Configure OBS
Open OBS and follow these steps:
- Navigate to Settings > Stream.
- Select Custom Streaming Server.
- Enter the RTMP URL:
rtmp://your-server-ip/live
. - Set a Stream Key (e.g.,
teststream
). - Click Apply and OK.
Step 4: Optimize OBS Settings
To ensure smooth streaming, adjust the following settings:
Resolution | Frame Rate | Bitrate (Kbps) |
---|---|---|
1920×1080 | 60fps | 6000-9000 |
1280×720 | 60fps | 4500-6000 |
1280×720 | 30fps | 3000-4500 |
854×480 | 30fps | 1000-2000 |
In Output Settings:
- Set Encoder to
x264
(orNVENC
if using an NVIDIA GPU). - Set Keyframe Interval to
2
. - Choose CBR (Constant Bitrate).
In Advanced Settings:
- Enable Network Optimizations for smoother connectivity.
Step 5: Start Streaming
- Click Start Streaming in OBS.
- Open VLC or another media player.
- Enter the RTMP URL:
rtmp://your-server-ip/live/teststream
. - You should see your live stream in action.
Additional Optimizations
- Use a Wired Connection: Avoid Wi-Fi for stable streaming.
- Monitor CPU Usage: Use
htop
to ensure OBS isn’t overloading the server. - Automate OBS Startup: Use
screen
orsystemd
to run OBS as a background process. - Enable Recording: Save streams locally for backup.
Conclusion
By following this guide, you can successfully set up a streaming server with OBS on Ubuntu. Whether you’re streaming to a private audience or a large platform, these configurations will help you achieve a stable and high-quality stream.