This is one of the frequently asked questions and probably most wanted feature by first time users of Raspberry Pi single-board computer, so I decided to write a brief article explaining how to watch YouTube and potentially any other online videos around the web, this method is fully supporting (VPU & GPU) hardware acceleration.
Well, the method that I recommend to use is very simple and it should work on Raspbian and Ubuntu, it involves two great command line software programs:
The "youtube-dl" tool will allow you to grab the direct link of a video on YouTube easily from your browser without downloading it, while "omxplayer" is used to play that video smoothly in real-time fully hardware accelerated which means it barely uses like 1% of the CPU power.
Install Required Tools
As far as I can tell, you should have "omxplayer" installed by default if you are already using the official Linux Raspbian OS recommended by the Raspberry Pi foundation or Ubuntu MATE as well. However, if you by any chance missing that software, I guess it won't hurt if I include instructions for installing it just in case.
Again, this software should already be installed by default on the official Linux distributions. If it got deleted, here's how you can re-install it, open a terminal by clicking on your keyboard (Ctrl + Alt + T) then input this into the command line:
sudo -s apt update apt install omxplayer exit
This one shouldn't be installed by default, to install it simply just issue these commands into the terminal:
sudo -s curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl chmod a+rx /usr/local/bin/youtube-dl exit
Start Watching YouTube
Okay, now you should be ready to enjoy watching videos, just open your favorite browser on "youtube.com" then enter into the search bar whatever you desire, while you're on the results page look for the video that you want, and do not click on the link but otherwise just right click on the title and select "Copy link address" then open the terminal once again (Ctrl + Alt + T):
sudo youtube-dl -g -f 22 "YOUTUBE-URL"
You can choose the quality of the video by changing the number after the "-f" which is currently set to (22) for 720p HD:
- youtube-dl -g -f best (Best Quality)
- youtube-dl -g -f 22 (720p)
- youtube-dl -g -f 18 (360p)
This will give you a video stream link, copy it. Then type this again into the same terminal window to run "omxplayer" and play the video on your screen:
omxplayer -b "COPIED LINK"
You can use and pair "omxplayer" with any other method to play online videos as well for different sites and not only YouTube, for example if you are using Chromium Browser which is currently the default application on Raspbian as a part of PIXEL Desktop Environment, there is an add-on called (Video DownloadHelper) which gives you the link of any video embedded in your browser session.