How to watch live streaming video from the command line on Linux

Last updated on September 24, 2020 by Dan Nanni

There are quite a few popular live streaming services on the web (e.g., Dailymotion, YouTube Live, UStream, etc.). Most of these streaming services are accessed from a web browser via flash plugin. If you heavily use some of those services on Linux, you may notice that your web browser sometimes becomes unresponsive or otherwise consumes a lot of CPU resource and even leaks memory. That is because of the misbehaving/malfunctioning flash plugin.

If you hate the flash plugin as much as I do, you can consider another way to enjoy streamed contents from those services.

Enter Livestreamer.

Livestreamer is a command line interface (CLI) client which, upon given a streaming URL, retrieves live streaming video from the URL, and pipes it into a native video player running on local host. So with Livestreamer, you can enjoy live streaming from various sources via a much stable and lightweight video player such as VLC or mplayer, without opening a web browser.

Currently, Livestreamer supports streaming from over 60 different web sites including Dailymotion, YouTube Live, Twitch/Justin.tv, Livestream and UStream.

In this tutorial, I will describe how to access live streaming from the command line with Livestreamer.

Install Livestreamer on Linux

For Ubuntu, Debian or Linux Mint:

$ sudo apt-get install python-pip
$ sudo pip install livestreamer

For Fedora, CentOS or RHEL:

$ sudo yum install python-pip
$ sudo pip install livestreamer

By default, Livestreamer attempts to pipe streaming video into VLC player. Thus you also need to install VLC player on your Linux system.

Watch Live Streaming from the Command Line with Livestreamer

To watch any live streaming channel/program, first obtain its corresponding URL from its official site.

For example, let's say the URL for the live streaming content that you want to watch is http://www.youtube.com/watch?v=U4Pw3ofFWgs

To check available streaming quality (i.e., bitrate) of the given content, simply run livestreamer command with the URL:

$ livestreamer http://www.youtube.com/watch?v=U4Pw3ofFWgs
[cli][info] Found matching plugin youtube for URL http://www.youtube.com/watch?v=U4Pw3ofFWgs
Available streams: 240p, 360p, 480p (best), 72p (worst)

To watch a live stream in the best available quality, run livestreamer command in the following format. This will automatically launch VLC player, and streaming will start on VLC.

$ livestreamer http://www.youtube.com/watch?v=U4Pw3ofFWgs best

To watch a live stream in specific streaming quality (e.g., 360p), run livestreamer as follows.

$ livestreamer http://www.youtube.com/watch?v=U4Pw3ofFWgs 360p

If you have your own favorite streaming player, you can let Livestreamer launch the player instead of default VLC, as follows.

$ livestreamer --player=mplayer http://www.youtube.com/watch?v=U4Pw3ofFWgs 360p

Livestreamer supports an external configuration file, where you can specify frequently used options for Livestreamer. The configuration file is useful especially when you are trying to access content in the subscription channels which require authentication. In such cases, you can specify whatever required access credentials (e.g., password, OAuth token, cookie, etc) in the configuration files.

Livestreamer configuration file can be created at either ~/.config/livestreamer/config or ~/.livestreamerrc.

The configuration file should contain one option per line in the format: option[=value].

For example:

http-proxy=http://hostname:port/
https-proxy=https://hostname:port/
player=mplayer -cache 2048

Support Xmodulo

This website is made possible by minimal ads and your gracious donation via PayPal or credit card

Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.

Xmodulo © 2021 ‒ AboutWrite for UsFeed ‒ Powered by DigitalOcean