If you are reading this, then probably you already have a YouTube channel and the live streaming feature has been enabled for the same. Before starting the live streaming to YouTube, you have to download the encoding software and configure it for streaming. These software allow you to capture the contents, including your desktop, camera, microphone, and more, and send it to YouTube Live for streaming. YouTube provides such software to download for platforms like Windows,Mac,iOS and Android but has not given any assistance to Linux users.
Let’s find out how to live stream to YouTube from Linux Mint or Ubuntu.
Before doing anything you need to have “ffmpeg” already installed in your system . You can install it through Software manager ( Software Center) or command line terminal. Here the command for installing “ffmpeg”.
sudo apt-get install ffmpeg
Download the zip file of script “stream_to_youtube.sh” from this link : https://gist.github.com/olasd/9841772. Then unzip or extract it.
Go to Creator Studio of your YouTube Channel for which you want the live streaming. From left side menu panel, select “Live Streaming” to open the live dashboard . This is like control room for the live streaming content.
On top-left corner you would find the Channel is presently OFFLINE. Scroll down the same page you can find the “Encoder setup” field. Just copy and save the “Server URL” and stream name/key ( to get the key, click on reveal) for later use.
For example (warning – do not share the streamkey to anyone) :
Server URL : rtmp://a.rtmp.youtube.com/live2
Stream name/key : u6pz-8bvs-jt60-17mp
Next edit the script that you have downloaded. Just right click on the file named “stream_to_youtube.sh” and open with any document editor ( ex – gedit, xed, etc)”. Edit the YOUTUBE_URL and KEY parameter with the value of Server URL and Streamkey respectively (refer Step-4). Save the file.
The source should be the location of the content that you want to stream. Suppose you want to use the webcam for live streaming then enter the source parameter as “/dev/video0”. If you want to stream a local video, then you have to specify the path of that video here, so that the script can read this. Just for ease, keep the video file along with this script into the same directory.
For example, first few lines of this script would look like this-
VBR="2500k" FPS="30" QUAL="medium" YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2" SOURCE="video.mp4" KEY="u6pz-8bvs-jt60-17mp"
Next open the command line terminal and change the present working directory to the directory containing the file “stream_to_youtube.sh”.
Make the file executable and then run this file.
chmod +x stream_to_youtube.sh
STEP 9 :
Wait for few seconds and open the YouTube live dashboard page. You would now see the status changed from OFFLINE to ONLINE. To close the live streaming, just go to the terminal again and press “Ctrl+c” to stop the process. The live streaming would automatically stop and the video archive would be exported to the video manager of your YouTube channel.