Hello! In this tutorial, you will learn how to live stream to YouTube using a free VPS without OBS or GPU. OBS does not support free VPSs that do not have a GPU.
You do not have to open your PC for a long time during the live stream and are able to keep an excellent connection with the YouTube server for YouTube unlisted live stream.
Step-up Free VPS on Oracle
I used the Oracle free tier for this tutorial. It is a free VPS. You can get two free VPS from Oracle’s cloud. Only you need to sign up for Oracle Cloud. If you have trouble with registration, watch the first part of this video. After registration, you can continue other steps.
The Oracle Cloud Free Tier gives you a small VPS server, and you are unable to keep high-quality HD streaming on that VPS. You can select a powerful, premium, cheap VPS server; check out these providers.
In your Oracle dashboard, click the “create a VM instance” button.
Name it, and use any name you prefer. Click “edit” under “configure and placement hardware“.
To change the OS, click the “change image” button and select Ubuntu 18.04 as your OS. Under network configuration, check whether you select “New virtual cloud network”.
You have to add an SSH key for the instance. Select “paste public key” to add the SSH key. You have to install Putty Key App to generate and connect to the VPS.
Check the description for the download link. After installation of the Putty app, open Putty Keygen. Click the “Generate” button, then move your cursor to this area.
Copy the SSH key and paste it. Click the “create” button to deploy the VM instance. It may take a few seconds. Save the private key in a safe place, it is necessary to connect the VM instance. You can see here, VPS is running.
Add Swap Space to Increase RAM
Copy the public IP address of the VPS. Open the Putty app and paste the public IP address as the hostname. Under SSH, click Auth to add the private key that you previously saved.
Now go back to the “session” tab and save your session using any name. Then you are able to connect it again without entering credentials again. Click open to enter the terminal window. Type “ubuntu” to log in to the virtual machine.
We have to add more memory to the VPS before starting the live stream. It helps to keep a smooth stream going.
free -m
Create a swap file and allocate space. I’ve used 1024 MB, but you can take more.
sudo dd if=/dev/zero of=/mnt/swap.0 bs=1024 count=1048576
Next, use this line to mount it.
sudo mkswap /mnt/swap.0
Switch to the root account to activate the swap.
sudo su
Use this to activate it.
echo "/mnt/swap.0 swap swap defaults 0 0" >> /etc/fstab
Next, use this command.
swapon /mnt/swap.0
Check if it’s created successfully.
sudo swapon -s
Check the memory’s main and swap sizes again. The swap file was created successfully.
free -m
Install FFmpeg Video Encoder on VPS
Type “exit” to log out as the root user. For live streaming using Linux, you have to install the FFmpeg video encoder. FFmpeg manipulates audio and video using command-line tools. Then we don’t want OBS Studio to broadcast.
Follow these commands one by one to install FFmpeg. First, use this to install the repository.
sudo add-apt-repository ppa:mc3man/trusty-media
Update the list of packages on your VPS using this code.
sudo apt-get update
Install FFmpeg using this command. Type “Y” to proceed.
sudo apt-get install ffmpeg
Once you use this command, you should see the result like this. It indicates the successful installation of the encoder.
ffmpeg -version
Upload files using SFTP FileZilla
You have to upload video and audio files using the SFTP client. I use FileZilla for this. You have to download and install this application before this step.
After installation, open the FileZilla client. Click the “server icon” at the top left corner. Then click the “new site” button to add a new server. Paste your public IP address as the host and 22 as the port. Change the protocol to SFTP, then change “Logging Type” to the key file.
Enter user “Ubuntu” and select your private key file that was saved before. After setting all of these, click the “connect” button to connect to the server.
Now, it is successfully connected to your remote server storage. In this application, the right-hand side is the remote server, and the left-hand side is your local machine.
On your local machine, select the file that you want to upload. Right-click on it and click “upload”. On the button, you can see the progress of the upload.
You can upload other files using this method. Copy the path to your file and paste it on the notepad. Then copy the file name and paste it at the end of the path that you copied. You have to do this with both video and audio files.
SCRIPT UPDATED FIX BUGS
#! /bin/bash
VBR="1500k"
FPS="24"
QUAL="superfast"
YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2"
KEY="z5k3-8888-69qu-9999"
VIDEO_SOURCE="/home/ubuntu/live 2.mp4"
AUDIO_SOURCE="/home/ubuntu/Music 5h.mp3"
ffmpeg \
-re -f lavfi -i "movie=filename=$VIDEO_SOURCE:loop=0, setpts=N/(FRAME_RATE*TB)" \
-thread_queue_size 512 -i "$AUDIO_SOURCE" \
-map 0:v:0 -map 1:a:0 \
-map_metadata:g 1:g \
-vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
-acodec libmp3lame -ar 44100 -threads 6 -qscale:v 3 -b:a 320000 -bufsize 512k \
-f flv "$YOUTUBE_URL/$KEY"
After that, you can get this streaming script in the guide. Please check the description. Replace the video and audio paths with your paths. You must use your key to replace the stream key. You can find it on the YouTube live stream page of the channel.
Connect to your VPS again using the SSH terminal. Use this code to list the files in this directory. You will see the uploaded files here.
Run Stream Script and Live on YouTube
After that, you have a new screen. It helps keep the live stream up and running after the closing of the SSH terminal. Use this command to install the screen.
sudo apt-get install screen
Use this code to navigate your new screen. Press “Space Bar” to proceed.
screen
Now paste your stream Script here and press “enter”.
Now your live stream has started. Visit the YouTube Live Stream Page to see it. You, Will, get an excellent connection with this. There is no need for a GPU or OBS to run live streams on YouTube.
Thank You. Have a good day. If you have anything comment below.
VBR=”4500k”
FPS=”30″
QUAL=”ultrafast”
YOUTUBE_URL=”rtmp://x.rtmp.youtube.com/live2″
KEY=”xxxxxxxxxxxxxxx”
VIDEO_SOURCE=”/home/ubuntu/filename.mp4″
AUDIO_ENCODER=”aac”
ffmpeg -stream_loop -1 -i “$VIDEO_SOURCE” -deinterlace -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR -acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b:a 712000 -bufsize 512k -f flv “$YOUTUBE_URL/$KEY”
What is the difference between the new 22.04 vs18.04 now, I need to increase the memory to the maximum capacity, then sudo dd if=/dev/zero of=/mnt/swap.0 bs=1024 count=1048576 The number behind count=1048576 needs Change /? thanks
You can use the new version of Ubuntu as well. If you want to change the swap size, you just need to change
bs=1024
that part only.Is it possible to set multiple live videos on one YouTube channel? if so How to set it? thank you
Actually, it is not possible because YouTube provides us with only one RTMP endpoint.
[…] How to VPS Live Stream on YouTube without OBS (VIDEO) […]
Hi
May you help with my doubts below.
I have this script
VBR=”1500k”
FPS=”30″
QUAL=”ultrafast”
YOUTUBE_URL=” rtmp://a.rtmp.youtube.com/live2″
YOUTUBE_KEY=”*****************”
VIDEO_SOURCE=”sample.mov”
AUDIO_ENCODER=”aac”
ffmpeg \
-stream_loop -1 \
-re \
-f lavfi \
-i “movie=$VIDEO_SOURCE” \
-c:v libx264 -preset $QUAL -r $FPS -g $(($FPS *2)) -b:v $VBR \
-c:a $AUDIO_ENCODER -threads 6 -ar 44100 -b:a 128k -bufsize 512k -pix_fmt yuv420p \
-f flv $YOUTUBE_URL/$YOUTUBE_KEY
and when I run it the output seems to indicate that it is streaming BUT nothing shows up in youtube
in youtube, it just says “Connect streaming software to go live
Viewers will be able to find your stream once you go live”
What could I be doing wrong?
check the all the steps correctly and try again. I will create a video with a new method soon.
when i close my putty terminal the stream buffers and stops please tell what is the solution
Use screen command and start your broadcast on the new screeen.
your script works well , thanks !
what i dont know is how to loop the video infinitely
loop=-1 is not working , not even =2 , to loop it twice .
Much appreciated if you will help me with that !
Hi Minex Tuts team, your tutorials are always excellent! I would like to know how it would be possible to live stream with a free Google Cloud VPS using Azuracast as the audio input method. I ask this because I tried to do these procedures on Google Cloud and it didn’t work correctly.
[…] of the Minex community forum, you will learn how to use this server for super-fast web hosting and live streaming on Facebook and YouTube. Let’s begin the setup, don’t miss important steps in the […]
[rootYTRXZ-l1 opc]# exit
exit
[opcYTRXZ-l1 ~]$ sudo add-apt-repository ppa:mc3man/trusty-media
sudo: add-apt-repository: command not found
[opcYTRXZ-l1 ~]$ [opcYTRXZ-l1 ~]$ sudo add-apt-repository ppa:mc3man/trusty-media
-bash: [opcYTRXZ-l1: command not found
[opcYTRXZ-l1 ~]$ sudo: add-apt-repository: command not found
-bash: sudo:: command not found
[opcYTRXZ-l1 ~]$ [opcYTRXZ-l1 ~]$
-bash: [opcYTRXZ-l1: command not found
[opcYTRXZ-l1 ~]$
Now script is fixed check using new one.
[…] in the terminal, after press “enter” to run it. You can see it is running now. Check it on your YouTube live stream dashboard. You can see it is successfully broadcasting on […]
It’s working, Hello please what if i want to stream videos from folder and loop them all please
i see this error it’s not working.
root@livestreamifitwork:~# #! /bin/bash
root@livestreamifitwork:~#
root@livestreamifitwork:~# VBR=”1500k”
root@livestreamifitwork:~# FPS=”30″
root@livestreamifitwork:~# QUAL=”ultrafast”
root@livestreamifitwork:~# YOUTUBE_URL=” rtmp://a.rtmp.youtube.com/live2″
root@livestreamifitwork:~# YOUTUBE_KEY=”z63s-jeq7-kj3d-mbqc-75wy”
root@livestreamifitwork:~# VIDEO_SOURCE=”/root/Road81676.mp4″
root@livestreamifitwork:~# AUDIO_ENCODER=”aac”
root@livestreamifitwork:~#
root@livestreamifitwork:~# $ ffmpeg
-c:a $AUDIO_ENCODER -threads 6 -ar 44100 -b:a 128k -bufsize 512k -pix_fmt yuv420p \
-f $YOUTUBE_URL/$YOUTUBE_KEY$: command not found
root@livestreamifitwork:~# -re \
> -f lavfi \
> -i “$VIDEO_SOURCE” \
> -c:v libx264 -preset $QUAL -r $FPS -g $(($FPS *2)) -b:v $VBR \
> -c:a $AUDIO_ENCODER -threads 6 -ar 44100 -b:a 128k -bufsize 512k -pix_fmt yuv420p \
> -f $YOUTUBE_URL/$YOUTUBE_KEY
Command ‘-re’ not found, did you mean:
command ‘re’ from deb re (0.1-7build1)
Try: apt install
root@livestreamifitwork:~#
You use different script here. use the command that indicate in the post and try again.
Immediately I paste it the code below on the new screen, it takes me back to normal screen with these errors.
I try digital ocean Ubuntu 18, and linodes Ubuntu 18 as well.
root@ubuntu-s-1vcpu-2gb-nyc1-01:~# screen
Command ‘-map’ not found, did you mean:
command ‘tmap’ from deb emboss
command ‘jmap’ from deb openjdk-11-jdk-headless
command ‘jmap’ from deb openjdk-8-jdk-headless
command ‘gmap’ from deb gmap
command ‘amap’ from deb amap-align
command ‘umap’ from deb libunicode-map8-perl
command ‘nmap’ from deb nmap
command ‘smap’ from deb slurm-client
command ‘pmap’ from deb procps
command ‘zmap’ from deb zmap
Try: apt install
root@ubuntu-s-1vcpu-2gb-nyc1-01:~# -map_metadata:g 1:g
-map_metadata:g: command not found
root@ubuntu-s-1vcpu-2gb-nyc1-01:~# -vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR
-vcodec: command not found
root@ubuntu-s-1vcpu-2gb-nyc1-01:~# -acodec libmp3lame -ar 44100 -threads 6 -qscale:v 3 -b:a 320000 -bufsize 512k
-acodec: command not found
root@ubuntu-s-1vcpu-2gb-nyc1-01:~# -f flv “$YOUTUBE_URL/$KEY”
here is what i paste in there. #! /bin/bash
VBR=”1500k”
FPS=”24″
QUAL=”superfast”
YOUTUBE_URL=”rtmp://a.rtmp.youtube.com/live2″
KEY=”z63s-jeq7-kj3d-mbqc-7tyr”
VIDEO_SOURCE=”/root/Road81676.mp4″
AUDIO_SOURCE=”/root/my first money musicedit.mp3″
ffmpeg
-re -f lavfi -i “movie=filename=$VIDEO_SOURCE:loop=0, setpts=N/(FRAME_RATE*TB)”
-thread_queue_size 512 -i “$AUDIO_SOURCE”
-map 0:v:0 -map 1:a:0
-map_metadata:g 1:g
-vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR
-acodec libmp3lame -ar 44100 -threads 6 -qscale:v 3 -b:a 320000 -bufsize 512k
-f flv “$YOUTUBE_URL/$KEY”
please help.
I have the same issue. Did you have any success?
Now script is fixed check using new one. sorry for the issue.
Hey buddy,
I found this interesting video of yours “How to VPS Live Stream on YouTube without OBS” on youtube. That’s an awesome video. I tried it and it is working and getting an Excellent connection while streaming. I have one query. While streaming, it is streaming audio at 128kbps. What if I want audio quality of 256kbps or 320kbps? How can I change that??
Any help would be appreciated.
Thank you 🙂
Try to change this line of the stream script by adding -ab command. (not tested)
-acodec libmp3lame -ab 256 -ar 44100 -threads 6 -qscale:v 3 -b:a 320000 -bufsize 512k \
I want to stream HTML web page just like Obs have webpage stream option. Is it possible?
I will try to find a way to do that if it is possible.
Please help , Like he said –
I also want to Stream via Web URL
It will on MineX Tuts Community Forum tomorrow.
Thanks for this guide. I have some special wishes and I’m a complete n00b to this so I really need some help.
I would like to do the following:
1. The code seems to stream video and audio separately. I would just like to only use an MP4 file (and use the audio of that file).
2. I would like to have the MP4 file loop indefinitely (until I stop the process).
3. I would like to be able to start multiple streams on the same Linux machine.
Can you please help me rewrite the ffmpeg code for this?
Hello, I open a new question for you and give a solution to test you. please check it here:
Thank You