How to set up a 24/7 YouTube Stream using a VPS Server

Published On:

If you are a content creator and especially engage in creating video content, then one of the great mediums to express yourself in a very interactive way is video streaming on one of the common platforms, like Twitch or YouTube. While these services provide a digital web platform to broadcast your stream, you still need your own hardware resources to run the stream. In this case, a great solution might be VPS web hosting. In the following article, we want to have a look at the scenarios where a VPS server for round-the-clock streaming is a viable option and then explore how to set up such a server.

When to use a Virtual Private Server for YouTube streaming?

While our typical idea of a YouTube video streamer is a guy who does something in real-time – like playing a video game, a musical instrument, or giving answers to the questions of the audience, not all streams work like this. On some occasions, you might want to stream some ready-made material in real time, whereby the streaming works on its own. The content you stream might be music radio a marathon of a show or any other type of video content.

In this case, instead of having to have your computer on all the time, with all the difficulties and inconveniences that come along with it, you can just rent a rather budget-friendly server that will provide continuous 24/7 operation of your streaming.

Benefits of using a VPS server for streaming

A VPS server is a reliable and versatile hosting solution that has a whole lot of possible applications apart from streaming videos.

It’s not the only hosting option, and two other popular hosting options include shared hosting and a dedicated server. However, VPS is probably the most suitable one when it comes to the main topic of this article, video streaming. The benefits of VPS include:

  • Dedicated resources: Although shared hosting is cheap, it doesn’t offer you dedicated resources to operate with, which instead a VPS does due to the virtualization technology it’s based on. For the purpose of continuous video streaming, you’ll need a sufficient amount of storage space to store numerous large video files. Also, you’ll want your streaming to run smoothly, without periods of poor performance or downtimes. All this can be easily provided on a VPS by a reliable provider.
  • Cost: Dedicated servers perform seamlessly, but they cost a lot. You would want to opt for such a solution for running complex projects that will require all the resources a server has to offer, if not even more. A VPS in turn is an extremely cost-efficient solution, with lower-tier plans starting with small pools of resources for a modest price and going up to pretty potent plans.
  • Scalability: You can choose a more modest plan at the beginning, but once your demands go up, you can easily upgrade the resources available. Since VPS is based on virtualization and is a dedicated virtualized part of a bigger server, you don’t even have to migrate all of your files and programs to a new server. Just contact your provider, ask them for an upgrade, and soon your streaming will get its second wind.
  • Additional services: Good hosting providers often offer additional services that you might find helpful. This can be DDoS protection, out of the box integration with certain solutions, or advanced server management.
  • Support: In case something goes wrong, a reliable provider is always here to help you with any technical issues.
  • Other uses of hosting: Besides the protagonist of this article, video streaming, you can also use your server to launch your website, host a video game, store files remotely, or for any other purpose you come up with. Just make sure you have a sufficient number of resources, otherwise, feel free to ask your host to scale up your VPS.

How to set up a 24/7 YouTube streaming VPS

DALL·E 2023 11 20 17.02.58 An informative and visually engaging image depicting the process of setting up a VPS server for 24 7 YouTube streaming. The image should feature a per

Step 1. Server selection

The first step before setting up your 24/7 YouTube streaming is the selection of a server. Find a reliable provider that offers plans that include all the resources you need and for an affordable price. The server should have enough storage space to host all the content you’re going to stream. Besides that, it should be provided with a high connection speed, a sufficient amount of bandwidth, and be housed in a data center that is close enough to major infrastructure backbones. For this reason, before looking for a server, you’ll have to perform certain calculations.

Step 2. Server setup

Once you’ve purchased your server, you can move on to setting it up.

First and foremost, you should connect to it via SSH. To do this, you’ll need the login credentials that you should have received from your service provider upon purchasing the capacities. Then you should use the corresponding SSH option depending on the operating system on your server. With a Linux server, SSH is done through the terminal on Linux and through PuTTY on Windows. In the case of a Windows server, you have to find Remote Desktop management on your Windows PC or use the Remmina client on Linux.

Now you need to follow the general routing of configuring your server. This involves such actions as changing the hostname, configuring time synchronization, updating the system, configuring iptables, and others.

There are also some more specific tasks that you should perform particularly for streaming:

  • Connecting to EPEL repository:

sudo yum install epel-release

  • Installing an FTP server;
  1. Install vsftpd (Very Secure FTP Daemon):

sudo yum install vsftpd

  1. Start and Enable the FTP Server:

sudo systemctl start vsftpd

sudo systemctl enable vsftpd

This will start the FTP server and ensure that it starts automatically at boot.

You can optionally configure vsftpd by editing the appropriate file to customize settings if needed:

sudo nano /etc/vsftpd/vsftpd.conf

For changes to take effect, restart vsftpd:

sudo systemctl restart vsftpd

  • Installing ffmpeg.

sudo yum install ffmpeg

ffmpeg is particularly worth attention since it allows you to perform a lot of operations related to video and audio editing. Its functions encompass recording, converting, and transferring audio and video files, in a variety of formats. With it, you can cut videos, take audio from video files, convert files in different formats, and more. One of the most relevant features of ffmpeg in the context of this article is converting files into streams, with further redirection to the corresponding streaming service.

Step 3. Broadcasting setup

After setting up the server and installing the necessary solutions, you can move on to setting up broadcasting on YouTube.

You’ll first need two things: a link and a broadcast key. Go to the streaming settings section of your channel and find them.

Afterwards, you have to create an ffmpeg script through a text editor:

#!/bin/bash

# Replace STREAM_KEY with your YouTube stream key

STREAM_KEY=”your_stream_key”

ffmpeg -stream_loop -1 -re -i your_input_source -c:v libx264 -preset veryfast -b:v 2500k -maxrate 2500k -bufsize 5000k -pix_fmt yuv420p -g 60 -c:a aac -b:a 128k -ac 2 -ar 44100 -f flv rtmp://a.rtmp.youtube.com/live2/$STREAM_KEY

Replace “your_stream_key” with your actual YouTube stream key. Also, adjust other parameters such as input source (your_input_source), video bitrate, audio settings, etc., as needed.

Then, upload your video files to the server with FTP.

Now, you can start streaming with ./start_stream.sh command.

Step 4. Configuring autonomy

To create a queue for files to be broadcasted, you need to create a queue script. The formula for it would be:

ffmpeg -re -i video1.mp4 -f flv rtmp://a.rtmp.youtube.com/live2/%KEY_TRANSLATION%ffmpeg -re -i video2.mp4 -f flv rtmp://a.rtmp.youtube.com/live2/%KEY_TRANSLATION%ffmpeg -re -i video3.mp4 -f flv rtmp://a.rtmp.youtube.com/live2/%KEY_TRANSLATION %nohup bash start.sh $

Replace video~.mp4 with the appropriate names of your files in the appropriate order.

Step 5. Configure streaming

Optionally, you can add some additional configuration to the stream. For example, the following script will make the name you want to give to the video fragment appear on the screen while the video is reproduced:

ffmpeg -re -i video1.mp4 -vf “drawtext=text=’Lecture 1′:x=(w-text_w)/2:y=(h-text_h)/2:fontcolor=white:fontsize=30:box=1:boxcolor=black@0.5” -f flv rtmp://a.rtmp.youtube.com/live2/%KEY_TRANSLATION%

The color and the size of the font as well as its location on the screen can be fine-tuned as you can see from the file.

Conclusion

Video streaming on YouTube is one of the popular ways of sharing your content nowadays. However, if you want to broadcast your content and do it continuously rather than being a live video streamer in person, you don’t need to have your PC on all the time. Instead, you can set up a streaming server, which will be a convenient, reliable, and cost-efficient solution, especially if you find a good provider. As you have seen, the configuration of such a server isn’t complicated either, so we hope that everything was clear and wish you success in YouTube video streaming.

newsletter subscription

Download FREE Twitch Growth Book + 2 Emoji Packs

Join the crew and download anything you like from our resource center.

author on the blog

Stefan Mitrovic

Stefan is a long-time content creator and one of the Stream Mentor's co-founders. He's a tech geek and a Dota 2 player (not even a good one) who wanted to help others become professional streamers and earn from the comfort of their home.

Follow me on:

Twitter

Instagram

LinkedIn