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.
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 20 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
To install Livestreamer on Debian, Ubuntu or Linux Mint:
$ sudo pip install livestreamer
To install Livestreamer on Fedora, CentOS or RHEL:
$ 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:
[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.
To watch a live stream in specific streaming quality (e.g., 360p), run livestreamer as follows.
If you have your own favorite streaming player, you can let Livestreamer launch the player instead of default VLC, as follows.
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]
http-proxy=http://hostname:port/ https-proxy=https://hostname:port/ player=mplayer -cache 2048
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.