Usually there are a couple of ways to view online videos on Linux – through desktop apps and through your Web browser. While there’s no problem in any of the two aforementioned approaches, per se, different users have different preferences. Some users might not prefer accessing streaming video services through Web browsers, and downloading separate clients isn’t an option for them.
So, what’s the way out? Well, simple. Access these services through popular and commonly-installed video players, such as a VLC. In this tutorial we’ll be specifically discussing the steps required to stream online videos on a VLC media player in Linux.
Stream online videos through a VLC media player in Ubuntu
To do this, you need to first have a tool called Streamlink which you can install using the following command:
Please note that
pip is a tool that lets you install and manage Python packages. If it’s not already installed on your system, you can install it using the following command:
Coming back to Streamlink, its default behavior is to play back a stream in the VLC player. While it’s least likely, in case you don’t have VLC installed as well, you can do so using the following command:
Once the tool is successfully installed, you can launch it the following way:
Available values for “stream-quality” include audio_webm, audio_mp4, 144p (worst), 240p, 360p, and 720p (best).
For example, if you want to play this YouTube video (with URL “https://youtu.be/B3OjfK0t1XM”), you can do so in the following way:
It’s worth mentioning that you don’t need to include the protocol when dealing with HTTP URLs, so “youtu.be/B3OjfK0t1XM” will also do in the above example.
Here’s the tool in action.
Note: for YouTube videos, there’s an easier way to stream them on VLC.
As described earlier, you can use Streamlink for streaming videos hosted on several popular video streaming services. Here’s another example screenshot showing the tool in action for a Dailymotion video.
To access the complete list of services the tool supports, head here.
Just to give you a basic idea on how exactly the tool works, Streamlink provides a means to extract and transport the streams, and the playback is done by an external video player. The official documentation says Streamlink works best with VLC or mpv, although many other players are supported as well – the complete list is available here.
If, with Streamlink, your player is running into frequent buffering, that’s because most players do not cache the data they receive from the tool. To solve this problem, you need to pass a player-specific command line parameter. More information on this, as well as other common Streamlink-related problems, is available here.
According to the tool’s website, Streamlink’s main purpose was to allow users to avoid buggy and CPU-heavy flash plugins but still enjoy various streamed content. However, since popular services like YouTube have already switched to HTML 5, that’s less of a reason to use Streamlink now. However, that doesn’t make the tool any less useful – it saves you from downloading dedicated clients for several video services at the very least.
Like I said in the beginning, whether or not you’d want to go with the solution described here purely depends on your personal preference. But it’s always good to know alternate ways of doing the same thing, as you never know when they might be of help to you.