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:
Install Required ToolsAs 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.
OMXPlayerAgain, 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:
raspberrypi:$ sudo -s raspberrypi:# apt-get update && apt-get install omxplayer raspberrypi:# exit
YouTube-DLThis one shouldn't be installed by default, to install it simply just issue these commands into the terminal:
raspberrypi:$ sudo -s raspberrypi:# curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl raspberrypi:# chmod a+rx /usr/local/bin/youtube-dl raspberrypi:# exit
Start Watching YouTubeOkay, 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):
raspberrypi:$ 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 22 (720p)
- youtube-dl -g -f 18 (360p)
raspberrypi:$ 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.
Do you want to lean more about methods for how to watch YouTube on Raspberry Pi? If you have any thoughts or questions do not hesitate to post in the comment section below.