5000+ Great Articles

Create Your Own Live Video Streaming Server With Linux

Most live streaming tools and sites are free to the public, but often require you to create an account, providing information you might not want to appear online. They may hide some content behind ads and include unclear Terms of Service that they may not even adhere to.

There are those who enjoy streaming live, but don’t need their videos to be available to the masses. Instead, they would rather have more control over their flow and the content they create. Open source software like Linux is the best answer to this hurdle.

Thinking ahead

Before you start setting up your own personal streaming server, you should ask yourself a few questions. First, what kind of broadcast quality are you looking for? Then, how many viewers do you expect to attract? Where will you store all your streaming content? Who will have access to this content?

System requirements can also be viewed as a problem. However, there are no set rules as to exactly what you need in this regard, so do yourself a favor and experiment to see what works best for your goals.

You will need to figure out which protocol will handle the audio and video portion of the streaming. Real Time Messaging Protocol (RTMP) is a great choice, but there are others like WebRTC that might be better for your situation. RTMP is widely supported, so we will focus on it in this article.

Another thing to worry about is the likely delays in your “live stream”. Just because you started living doesn’t mean everything will be perfect. Video streams need to be encoded, transmitted, buffered and displayed, so expect a little tweaking of stream attributes to be required.

– / pre>

Linux Server Setup

Ubuntu Linux is my personal favorite, so I’ll pick this version here. For those who prefer the GUI option, Ubuntu Desktop is available.

sudo apt update sudo apt upgrade

We will be using Nginx web server for this streaming server. Install it:

sudo apt install nginx

Purchase the RTMP module so Nginx can handle your media stream:

sudo add-apt-repository universe sudo apt install libnginx-mod-rtmp

Configure Nginx so that it can receive and deliver your media stream.

sudo nano /etc/nginx/nginx.conf

Add the following code to the end of the config file:

rtmp {
server {
listening 1935;
chunk_size 4096;

the application is running {
enabled;
recording is disabled;
}
}
}

Save the configuration file as we will use it later to create a working streaming server.

Restart Nginx with the new configuration:

sudo systemctl restart nginx

Set up broadcast software

The server is ready, now it’s time to set up your streaming software. Let’s use Open Broadcaster Software (OBS) in this run.

In the Stream section, set the Stream Type to Custom and enter the following URL in the Server field:

rtmp: // IPaddress / live

Replace the IP address with the IP address of your streaming server.

Now create your own stream key and enter it in the stream key field. Make it something to remember and write it down. For added security, select the Use Authentication checkbox and add the required credentials.

At the end, click Apply and then click OK.

Everything should now be set up for streaming. To start your first stream, click the Stream Now button. The button will change to Stop Streaming if everything was done correctly. Your stream’s bandwidth metrics will appear at the bottom of the OBS window.

Be the first viewer

There are many open source media players that support RTMP, the most famous of which is the VLC media player Install and run this software, click the “Media” tab and select “Open Network Stream” from the menu.

Do you have the key to the flow at hand? Enter the path to your stream and include the stream key you set earlier at the end of it. It should look like this:

rtmp: // IPaddress / live / SecretKey

Click “Play” and you will see your live stream.

Additional Measures

Now that the basics are mastered, limiting access to the streaming server and the ability to record and save videos are two more factors that might interest you.

By default, anyone can view your stream. This may go against the goal of creating a server in the first place. You need to set up restricted access using Linux firewall, .htaccess file, or built-in access controls in the RTMP module This choice is yours.

The Nginx configuration given here will only allow you to stream videos, not save them. To add a storage parameter, in the Nginx configuration, just below the RTMP section, you can configure the stream recording parameters and specify where you want to save and save your content.

Set an existing path to allow Nginx to write to it. Enter the following:

live application {
live;
write everything down;
record_path / var / www / html / records;
record_unique on;
}

That’s all you need to set up a streaming server using Ubuntu Linux OS. If you are more interested in a streaming media server that does not support live streaming, I would suggest using Plex instead of OBS.

Exit mobile version