How to Set Up a Video Streaming Server

 In Case Study, Streaming

Setting up your own video streaming server can save money, improve reliability, and give you full control over your streams. Here’s what you need to know:

  • Why Do This? Streaming from home can be unreliable due to internet dropouts or ISP throttling. A VPS-based server ensures better uptime, bandwidth, and flexibility.
  • What You Need: A Linux VPS (Ubuntu is a good option), basic command-line skills, and streaming software like NGINX-RTMP, SRS, or Icecast.
  • Costs: VPS plans start at $20–$40/month for setups that handle multiple streams.
  • Options: Choose between live streaming, video-on-demand (VOD), multistreaming, or audio-only setups based on your needs.

Types of Streaming Servers Explained

Before diving into the world of streaming servers, it’s important to understand the different types available and how they align with your goals. The term “streaming server” covers various setups, each tailored for specific needs. These setups require distinct software, resources, and configurations, all of which should influence your VPS choice and setup.

Live Video Streaming Servers (RTMP/SRT)

 

Live video streaming servers are designed for real-time broadcasts with minimal delay. Here’s how they work: video from an encoder like OBS is sent to the server, which processes the stream and either delivers it directly to viewers or forwards it to platforms such as Twitch or YouTube. Two key protocols dominate this space: RTMP (Real-Time Messaging Protocol) and SRT (Secure Reliable Transport).

  • RTMP: Despite Adobe discontinuing Flash in 2020, RTMP remains widely used due to its compatibility with most streaming platforms.
  • SRT: A newer option, SRT excels in handling unstable networks by recovering lost packets and dynamically adjusting bitrate.

Tools like NGINX with the RTMP module allow a standard web server to ingest RTMP streams and deliver HLS for web playback. Alternatively, SRS (Simple Realtime Server) supports both RTMP and SRT natively, while also offering transcoding and recording capabilities.

Live video servers are ideal for gaming streams, webinars, sports broadcasts, and more. For basic setups (50–100 viewers without transcoding), a VPS with 2 vCPUs, 4 GB of RAM, and a 1 Gbps network port is sufficient. If you’re adding transcoding for multiple resolutions (e.g., 1080p, 720p, 480p), upgrading to 4 vCPUs and 8 GB of RAM is recommended.

Video-on-Demand (VOD) Servers

VOD servers are perfect for hosting pre-recorded videos, delivering them whenever users request. The process involves uploading video files, transcoding them into HLS format with multiple bitrate options using tools like FFmpeg, and serving the resulting segments via a web server such as NGINX.

This setup works well for platforms offering online courses, exclusive membership content, or archives of live events. Unlike live streaming, VOD servers experience CPU spikes during transcoding but require fewer resources during playback. A VPS with 2 vCPUs and 4 GB of RAM can typically handle transcoding videos under 2 hours and serve content to over 100 viewers. Keep in mind, storage is a major factor – an hour of 1080p video in HLS format can take up 2–4 GB of disk space.

Multistream Relay Servers

A multistream relay server simplifies broadcasting to multiple platforms simultaneously. Instead of streaming separately to Twitch, YouTube, and Facebook, you send one stream to your VPS, which then distributes it to all platforms. This setup ensures smooth delivery even if one platform experiences issues, thanks to retry logic and buffering.

Commonly implemented with NGINX-RTMP, this setup defines one source stream (your encoder) and multiple destinations. Bandwidth is a key consideration – streaming at 6 Mbps to three platforms requires 18 Mbps of upload capacity. A VPS with 4 vCPUs, 8 GB of RAM, and a 1 Gbps network port can support this, assuming your provider doesn’t throttle uploads or charge overage fees.

Audio/Radio Streaming Servers (Icecast/Shoutcast)

Shoutcast website homepage promoting radio streaming and monetization, featuring subscription plan details and email sign-up form.

Audio streaming servers are far less demanding than their video counterparts. Without video frames to process, even a modest VPS can handle hundreds of listeners. Icecast2 is a popular open-source solution for internet radio, supporting formats like MP3, Ogg Vorbis, and Opus.

Setting up an audio server involves installing Icecast, configuring mountpoints (the URLs where listeners connect), and securing the broadcast with source passwords. This setup is widely used by online radio stations, podcast networks, and music channels.

For example, streaming 128 kbps MP3 audio to 100 listeners uses about 12.8 Mbps of bandwidth. A VPS with 1 vCPU and 2 GB of RAM can handle over 200 listeners, making it an affordable option, often costing $10–$15 per month.

Plan your next stream

Choose your workflow, estimate reach, and grab the best-fit server plus a go-live link in under a minute.


Select your workflow

📡
Restreaming

Push a single master feed to Twitch, YouTube, Kick, and more without maxing your home uplink.


3 destinations

1
10
Required throughput: 18 Mbps

1080p · 6,000 kbps

24/7 Continuous Streaming Servers

For non-stop broadcasts, such as webcam feeds, looping promotional videos, or ambient content channels, 24/7 streaming servers (full guide here) are the way to go. These setups often use FFmpeg to loop through playlists or maintain a constant live feed.

Reliability and uptime are the priorities here. Choose a VPS with dependable resource management to ensure your stream remains online without interruptions. While raw performance is less critical, consistent uptime is essential for these continuous streams.

Selecting Your Server Stack and VPS Specifications

Picking the right combination of software and hardware is key to avoiding wasted resources or performance issues like dropped frames. Your choice should be based on your specific streaming needs, not what seems popular in online discussions. Building on the streaming server types we’ve covered, your server stack and VPS specs should align with what you’re broadcasting.

Matching Streaming Needs to Software Stacks

The software you select determines how your server processes streams, handles video, and delivers content to viewers. Each stack has its strengths, tailored to specific streaming scenarios. Here’s how they compare:

NGINX with the RTMP module is a top choice for live video streaming. It’s lightweight, stable, and easy to configure. You define an RTMP application block, set up HLS output, and you’re ready to stream. This setup is ideal for single-stream broadcasts with 50–500 viewers and doesn’t require complex transcoding.

SRS (Simple Realtime Server) provides more flexibility than NGINX-RTMP, supporting both RTMP and SRT in one package. It also handles transcoding and offers WebRTC for ultra-low-latency playback. This makes it great for platforms needing multiple bitrate outputs or experimenting with sub-second latency. The trade-off? Higher CPU usage – SRS typically consumes 30–40% more CPU than NGINX-RTMP during transcoding.

FFmpeg is the ultimate tool for streaming workflows, though it’s not a server on its own. It excels in tasks like looping video playlists for 24/7 streams or splitting a single input into multiple outputs with different encoding profiles. While its command-line interface can be intimidating, mastering it unlocks endless automation possibilities. For example, a 24/7 stream using FFmpeg with an MP4 playlist typically uses about 1.5 vCPUs.

Icecast2 is the go-to option for audio streaming. Designed specifically for this purpose, it handles audio streams efficiently without worrying about video complexities like frame rates. Configuration is simple – set mountpoints, source passwords, and listener limits. For an internet radio station streaming 128 kbps MP3 audio, Icecast can support over 200 listeners on a single vCPU.

Node-Media-Server, built on Node.js, is perfect for developers who prefer JavaScript. It offers RTMP ingestion and HLS output with minimal setup. Its programmability is a major advantage, allowing custom authentication or integrations with other Node.js applications. However, it’s less efficient than NGINX-RTMP, using 20–25% more CPU for the same workload.

VPS Resource Requirements by Streaming Type

Proper resource planning ensures you don’t overpay for unused capacity or face performance issues during broadcasts. Once you’ve chosen your software stack, calculating VPS specs becomes straightforward.

Streaming Type Recommended Stack vCPUs RAM Bandwidth Monthly Cost Range
Gaming / Live Events NGINX-RTMP or SRS 2–4 4–8 GB 1 Gbps $15–$35
VOD / Course Hosting NGINX + FFmpeg 2 4 GB 500 Mbps $12–$20
Multistream Relay NGINX-RTMP 4 8 GB 1 Gbps $25–$40
Internet Radio Icecast2 1–2 2 GB 500 Mbps $8–$15
24/7 Looping Stream FFmpeg 2–4 4 GB 1 Gbps $15–$30

For setups without transcoding, 2 vCPUs and 4 GB RAM are usually enough. Adding transcoding for multiple resolutions doubles CPU requirements, though RAM usage stays moderate. For example, transcoding a 1080p60 stream into three lower resolutions with x264 encoding uses about 3.5 vCPUs. The operating system needs 1–1.5 GB, while NGINX or SRS takes up 200–500 MB. If you’re running multiple services or handling 10+ streams, bump up to 8 GB of RAM.

Bandwidth planning is crucial to avoid overage charges or throttling. A 6 Mbps stream to 100 viewers requires 600 Mbps of outbound bandwidth. Adding a 20% buffer for overhead brings the total to 720 Mbps. For multistream relay, multiply your upload bitrate by the number of platforms – for instance, streaming 6 Mbps to Twitch, YouTube, and Facebook simultaneously needs 18 Mbps upload capacity.

Storage needs depend on your use case. Live-only streaming requires minimal disk space – about 20–40 GB for the OS, software, and temporary HLS segments. VOD platforms need much more. An hour of 1080p video in HLS format with multiple bitrates uses 2–4 GB. A course platform hosting 50 hours of content would require 100–200 GB, plus extra for growth.

Network port speed impacts how many viewers you can serve at once. A 1 Gbps port can theoretically handle 166 viewers at 6 Mbps each, but real-world performance maxes out at about 120–130 viewers due to protocol overhead. If you expect 200+ concurrent viewers, look for VPS options with 2.5 Gbps or 10 Gbps ports.

Geographic location plays a big role in latency. A viewer in Los Angeles connecting to a Frankfurt server might experience 150–180 ms of latency, while connecting to a Los Angeles server reduces it to 5–15 ms. For live interactive streams, aim for latency under 50 ms by choosing a VPS near your audience.

These specs provide a solid starting point. If you’re adding advanced features like DVR, real-time transcoding, or serving thousands of viewers, you’ll need to double your CPU and RAM. Start with the baseline specs for your streaming type, monitor usage during the first week, and adjust as needed. Most VPS providers allow upgrades without requiring a full reinstall.

How to Set Up a Live Video Streaming Server

Creating your own live streaming server gives you complete control over your broadcasts. This guide will walk you through setting up NGINX with the RTMP module on a Linux VPS – a lightweight and reliable solution that can handle hundreds of viewers with ease.

Setting Up Your VPS and Basic Configuration

To get started, you’ll need a VPS. Deploy a fresh instance running Ubuntu 22.04 LTS or Debian 12 – both are stable and have excellent package support for streaming servers.

Once your VPS is up and running, connect to it via SSH using your terminal or an SSH client. Most providers grant root access initially, but performing tasks as root can be risky. Instead, create a dedicated user with administrative privileges:

adduser streamadmin 
usermod -aG sudo streamadmin 
su streamadmin

Replace “streamadmin” with your preferred username. After setting up the user, update your system:

sudo apt update && sudo apt upgrade -y

Next, configure your firewall to protect the server. Ubuntu includes UFW (Uncomplicated Firewall), which simplifies port management. Open the necessary ports for streaming:

sudo ufw allow 22/tcp 
sudo ufw allow 1935/tcp
sudo ufw allow 80/tcp 
sudo ufw allow 443/tcp 
sudo ufw enable
  • Port 22: SSH access
  • Port 1935: RTMP streaming
  • Ports 80/443: Web traffic for HLS playback or future statistics pages

Verify the firewall rules using:

sudo ufw status

You should see these ports marked as “ALLOW.”

Installing NGINX with the RTMP Module

sudo apt install speedtest-cli -y speedtest-cli

NGINX doesn’t include RTMP support by default, but you can add it by installing a prebuilt module. This is faster and easier than compiling from source.

Install NGINX and the RTMP module with this command:

sudo apt install nginx libnginx-mod-rtmp -y

To confirm that the RTMP module is installed, run:

nginx -V 2>&1 | grep rtmp

You should see output indicating the RTMP module is available. Next, enable NGINX to start automatically on reboot:

sudo systemctl enable nginx

Now, configure NGINX for live streaming. Open the configuration file:

sudo nano /etc/nginx/nginx.conf

Scroll to the bottom of the file and add this RTMP configuration:

rtmp {
    server {
        listen 1935;
        chunk_size 4096;

        application live {
            live on;
            record off;
        }
    }
}
  • listen 1935: Listens for RTMP connections on port 1935.
  • chunk_size 4096: Balances latency and CPU usage.
  • live on: Enables real-time streaming.
  • record off: Prevents the server from saving streams (you can enable this later if needed).

Save the file (in Nano, press Ctrl+O, Enter, then Ctrl+X) and test the configuration:

sudo nginx -t

If the test passes, reload NGINX to apply the changes:

sudo systemctl reload nginx

Your server is now ready to accept RTMP connections at rtmp://your-server-ip/live.

Testing Your Stream and Adding Security

To test your setup, open OBS Studio on your computer. Under Settings > Stream, choose “Custom” as the service and enter:

  • Server: rtmp://your-server-ip/live
  • Stream Key: test (or any identifier you prefer)

Adjust the video bitrate under Settings > Output. For 1080p60 streams, a bitrate of 6,000 Kbps works well if your upload speed is at least 8 Mbps. Also, set the keyframe interval to 2 seconds under Settings > Advanced for smoother playback.

Click “Start Streaming” in OBS. Once connected, you can view your stream using VLC Media Player. Go to Media > Open Network Stream and enter:

rtmp://your-server-ip/live/test

You should see your stream with a slight delay of 2–4 seconds, which is normal for RTMP.

To secure your server, prevent unauthorized users from hijacking your stream. Without protection, anyone who discovers your server’s IP can stream to it, wasting bandwidth or broadcasting inappropriate content.

Edit the NGINX configuration again:

sudo nano /etc/nginx/nginx.conf

Update the “application live” block to restrict publishing:

application live {
    live on;
    record off;

    allow publish 127.0.0.1;
    allow publish YOUR_LOCAL_IP_ADDRESS;
    deny publish all;
}

Replace with your actual IP address (you can find it at whatismyip.com). This ensures only your IP and localhost can publish streams, while others can still view them. For more advanced security, consider implementing token-based authentication using the “on_publish” directive and a custom validation script.

Reload NGINX to apply the changes:

sudo systemctl reload nginx

Test the security by attempting to stream from an unauthorized IP – it should fail. Streams from your approved IP should work as expected.

Monitor your server’s performance during test streams. A single 1080p60 stream at 6 Mbps typically uses 15–25% of one CPU core. If usage exceeds 60% with one stream, your VPS may need an upgrade. Check NGINX error logs for troubleshooting:

sudo tail -f /var/log/nginx/error.log

From here, you can expand your setup to include HLS output, DVR functionality for replays, or multi-bitrate transcoding for adaptive streaming.

Scaling, Security, and Troubleshooting

Once your streaming server is up and running, you’ll eventually encounter three challenges: scaling to accommodate more viewers, securing your server from threats, and resolving technical issues. Each requires specific strategies to address effectively.

Scaling for More Viewers

A single VPS can handle a limited number of viewers, ranging from dozens to a few hundred. But as your audience grows, your server’s CPU and bandwidth may struggle to keep up.

To manage this, consider horizontal scaling. Instead of upgrading to a larger VPS, you can distribute the load across multiple servers located in different regions. Your main server will ingest the stream from OBS and push it to regional relay servers, which then handle local viewer connections. For instance, if you’re streaming from a server in Atlanta but notice buffering issues for European viewers, adding a relay server in Frankfurt can significantly reduce latency for that audience.

To configure a relay, update your primary server’s NGINX settings to push the stream to secondary locations:

application live {
    live on;
    record off;

    push rtmp://frankfurt-server-ip/relay;
    push rtmp://singapore-server-ip/relay;
}

On each relay server, set up a separate application block

 

application relay {
    live on;
    record off;

    allow publish primary-server-ip;
    deny publish all;
}

This setup ensures only your primary server can push to the relays, protecting against unauthorized streaming. By distributing the load, viewers receive a localized feed, reducing latency and improving performance.

Bandwidth usage grows with your audience. A 1080p stream at 6 Mbps requires 6 Mbps per viewer. For 100 viewers, that’s 600 Mbps. While VPS plans often advertise 1–10 Gbps ports, real-world speeds usually reach only 60–70% of that due to network overhead. If your audience exceeds 500 concurrent viewers, consider upgrading to a dedicated server. Dedicated hardware ensures consistent performance and minimizes the impact of shared resources. Additionally, transcoding for multiple bitrates can be resource-intensive. A single 1080p-to-720p transcode can max out a CPU core. To manage this, use a dedicated VPS for transcoding, leaving your main server to handle the stream.

As you scale, securing your setup becomes just as important.

Protecting Your Streaming Server

Public streaming servers are vulnerable to bandwidth theft, DDoS attacks, and unauthorized access. Strengthening your server’s security is crucial.

One effective measure is token-based authentication. By generating a unique token for each session, you can validate streams before accepting them. To implement this, use the on_publish directive in NGINX and set up a Node.js validation endpoint:

  1. Install Node.js
    sudo apt install nodejs npm -y
  2. Create a validation script at /usr/local/bin/stream-auth.js:
    const http = require('http');
    const url = require('url');
    
    const validTokens = ['your-secret-token-123', 'another-token-456'];
    
    http.createServer((req, res) => {
        const query = url.parse(req.url, true).query;
        const token = query.token;
    
        if (validTokens.includes(token)) {
            res.writeHead(200);
        } else {
            res.writeHead(403);
        }
        res.end();
    }).listen(8080);
    
  3. Run the script:
    node /usr/local/bin/stream-auth.js &
    
  4. Update your NGINX configuration:
    application live {
        live on;
        record off;
    
        on_publish http://localhost:8080/auth;
    }
    
    

    When streaming from OBS, append the token to your stream key (e.g., rtmp://your-server-ip/live/streamname?token=your-secret-token-123). This ensures only valid tokens are accepted.

To guard against DDoS attacks, you can limit connection rates in NGINX:

rtmp {
    server {
        listen 1935;
        chunk_size 4096;

        max_connections 100;

        application live {
            live on;
            record off;
        }
    }
}

For more robust protection, consider using a reverse proxy or CDN that supports RTMP proxying. Additionally, tighten your firewall rules. If you stream from a single location, whitelist your IP address and block all other RTMP connections:

sudo ufw delete allow 1935/tcp
sudo ufw allow from YOUR_IP_ADDRESS to any port 1935 proto tcp

Monitor your server’s activity regularly. Tools like iftop can help you track real-time bandwidth usage:

sudo apt install iftop -y
sudo iftop -i eth0

If you detect suspicious activity, block the offending IP immediately:

sudo ufw deny from SUSPICIOUS_IP_ADDRESS

Once your server is secure, focus on troubleshooting common issues.

Fixing Common Streaming Problems

Even with a well-optimized setup, issues like dropped frames, audio desync, or playback delays can arise.

Dropped frames often mean your upload speed can’t handle the stream’s bitrate. Check OBS’s stats panel during a live stream. If dropped frames exceed 1–2%, test your server’s upload speed:

sudo apt install speedtest-cli -y
speedtest-cli

If your upload speed is insufficient, network limitations may be the culprit. High CPU usage can also cause dropped frames. Use monitoring tools to check server performance:

top

If NGINX or FFmpeg is consuming too much CPU, consider upgrading your VPS or offloading tasks like transcoding to a dedicated server. Regular monitoring and adjustments will help keep your streams running smoothly.

Summary and Next Steps

Setting up a video streaming server on a VPS gives you complete control over your streaming experience, offering flexibility and potential long-term savings. This setup allows you to fine-tune your system and scale as needed, ensuring reliable performance. To achieve this, you’ll need specialized media software like HLS or DASH and hardware optimized for smooth streaming.

With your server up and running, you can start exploring advanced options to enhance your service. For instance, you might deploy servers in multiple regions to reach a global audience, add DVR functionality for playback, or create custom authentication systems for private streams. Real-time analytics can help track viewer engagement, while experimenting with WebRTC can bring ultra-low-latency streaming to your platform. These steps can help you refine your setup and strengthen your streaming infrastructure.

Recent Posts

Leave a Comment

Contact Us

Your message has been sent!

Thank you! We’ll take a look at your request and get in touch with you as quickly as possible.

Let us know what you’re looking for by filling out the form below, and we’ll get back to you promptly during business hours!





    Start typing and press Enter to search