Create a Streaming Server with OBS and Ubuntu
OBS Studio is a powerful open-source tool. It helps in streaming and recording videos smoothly.
Moreover, Ubuntu (a popular Linux operating system) works great with OBS. So, if you set up a streaming server with OBS on Ubuntu, it gives you full control over your content. You do not need to depend on third-party platforms and get better privacy and customization.
This setup is useful for various purposes, such as gaming, live events, or educational content.
OBS and Ubuntu together give you a stable and reliable environment. Also, the right configuration can help you stream high-quality videos.
You need to prepare your Ubuntu system before setting up your streaming server. So, let us go through the prerequisites, starting with getting a fresh Ubuntu Server with good hardware on a server like Cantech.
Other Prerequisites
Ensure you have at least 2 virtual CPUs, 4GB RAM, and 80GB storage for smooth performance. Also, a bandwidth of 3TB or more is recommended.
Another essential aspect is SSH access (connect as a non-root user with sudo privileges). Moreover, you must install a desktop environment on your server.
Installation of OBS Studio on Ubuntu
Ubuntu makes it easy since OBS is available in its repositories.
=> First, update the system to get the latest packages. For that run –
sudo apt update && sudo apt upgrade -y
=> After the update is done, install OBS Studio along with FFmpeg (a tool to handle multimedia files) –
sudo apt install ffmpeg obs-studio -y
Configure Streaming Platform
- Open ‘YouTube Studio’ (in case of YouTube streaming). Then, click ‘Create’ in the top right and choose ‘Go Live. ’
- Next, schedule your stream in the ‘Manage’>’ Schedule Stream’ section. Further, add a title, description, and category.
- Also, upload a thumbnail if needed.
- Select your audience and other Customization options. Click on the Next button.
- Stream visibility must be set to Public for the date you want to stream it. Lastly, click on the Done button.
- Ensure “Auto-start” is turned on in Stream Settings.
- Copy the stream key (you will need it in OBS).
The process is similar if you are streaming on Twitch or other platforms. You simply need to find the stream key and RTMP URL from the respective platform’s settings.
Configure OBS Studio for Best Performance
You first need to access your Ubuntu server’s desktop remotely to access OBS. You can do this using software like VNC Viewer or NoMachine.
- Log in as a non-root user and open the Applications menu. Next, look for OBS Studio and launch the application (the Auto-Configuration wizard will pop up). You will want to select the “Optimize for streaming, and recording is secondary” option in the wizard. Then, ‘Next. ’
- After that, click Next again without changing the video settings.
- Click on YouTube or YouTube Gaming from the list from the Service drop-down. Now, paste your YouTube stream key into the provided field. Click on the Next button to test the optimal settings for your stream.
- After the test ends, finalise by clicking on ‘Apply Settings. ’ Close the wizard.
- Next, click on the Settings option (or you can navigate via File > Settings) within the OBS Studio interface. Access the Video section to adjust both the base canvas and output resolution.
- For 2 or more vCPUs on a server, it is advisable to use a resolution of 720p (1280×720). (Keep in mind that with the resolution and FPS higher, it needs higher processing power OBS)
- You also need to change the Common FPS Value to 30 or higher (as per the quality of stream that you want). Then, go to the Output section and adjust the video bitrat
Ensure the bitrate fits the stream resolution as per the recommended ranges listed below:
852×480 resolution at 30 FPS – 500 to 2000 Kbps.
1280×720 resolution at 30 FPS – 1500 to 4500 Kbps.
1280×720 resolution at 60 FPS – 2500 to 6500 Kbps.
1920×1080 resolution at 30 FPS – 3000 to 6500 Kbps.
1920×1080 resolution at 60 FPS – 4500 to 9500 Kbps.
3840×2160 resolution at 30 FPS – 13000 to 34000 Kbps.
3840×2160 resolution at 60 FPS – 20000 to 51000 Kbps.
- Click ‘Apply’ after adjusting these settings.
- Then, go to the Advanced section > Automatically Reconnect area. Set values as –
Retry Delay – 3 seconds or less
Maximum Retries – at least 1000.
- Click OK to save and exit.
- The Studio Mode option turns on both the Preview and Program screens.
- Then, you can proceed with setting up the stream. Click on the + symbol in the Sources section to add your video and audio sources. Also, verify that your sources are feeding properly. Then, to
- move the content to the live program screen, click ‘Transition. ’
- Lastly, click the “Start Streaming” button.
Open a web browser and go to your YouTube channel to check that the stream is live.
** Keep monitoring the CPU usage rate in OBS while streaming. Above 90% means it may cause frame drops or buffering. You can fix this by lowering your output resolution or upgrading your server’s vCPUs.
- Finally, disconnect from the Ubuntu desktop, but keep your stream running. You can log back in anytime to check that OBS is working without any issues.
Set up a Self-hosted Stream Server like Owncast
- Deploy an Owncast server and launch a fresh Windows Server 2022 instance on Cantech. (OBS Studio works best on Windows, so you can install it on the latest Windows Server edition for a more stable experience.)
- Use RDP (Remote Desktop Protocol) and access the Windows Server.
- Both Ubuntu and Windows servers need to be within the same Cantech Virtual Private Cloud (VPC) for a secure and fast connection.
- Use the ping utility and test communication between the servers.
Installing and Configuring OBS on Windows Server
- Open a browser on your Windows Server, visit the official website and follow the installation prompts to download the OBS Studio installer. After the installation. Open it from the start menu. The auto-configuration wizard will open, and you will need to select ‘Optimize for streaming’ and proceed.
- Choose ‘Custom’ as the streaming service and enter the RTMP address for your Owncast server (e.g., rtmp://192.0.2.1/live). Next, add the stream key and test the connection.
- Click ‘Apply Settings’ after the connection test is successful.
Now go to the Settings menu and adjust your video resolution and bitrate to match your desired stream quality. Go to the ‘Advanced’ section and set the retry delay to 3 seconds or less (follow the earlier steps).
Configuring Windows Server for Continuous Streaming
When you use Windows Server, your remote desktop session is counted as a single user session. So, when you disconnect it, the server might lock. This could stop your stream.
You can keep the server active by using the ‘tscon’ utility to send your RDP session to the console.
- Open the Command Prompt or PowerShell on the Windows Server.
- Use the following command to view your RDP session –
> qwinsta
- You can use the tscon tool to send your remote desktop connection to the console. This will keep everything running smoothly without interruption. To do this, type the following command:
> tscon rdp-tcp#2 /Dest:Console
- You run this, and your remote desktop connection will automatically close. However, OBS will continue to run. It will stay active until you log in again or make any changes to the server settings.
- Install TightVNC to monitor your Windows Server and adjust the console resolution. Connect to the VNC session when you have sent the remote desktop to the console. This way, you can keep track of your server’s performance.
You can always check the live stream by visiting your stream server’s URL. Make sure it is running smoothly.
Connect to your Windows Server using VNC in case of buffering during your stream. You need to check if the OBS CPU usage is under 90%. You can lower the resolution if it is high so that OBS consume fewer server resources and avoids buffering.