Subscribe to the feed

As a system administrator, you probably spend a lot of time at your terminal. We all have a tool that we begrudge having to leave the command line to use, whether it's for a web browser or a desktop GUI application.

If you poke around GitHub for long enough, you can find a command line utility to replace the graphical front end of just about every service out there, at least those with an accessible API. Some of these tools work better than others, of course, but a lot of them are worth poking around to see if they work for you.

Today we're going to look at three tools for enjoying sound and video at your Linux terminal: youtube-dl, mplayer, and cava. I originally profiled these tools as a part of my 24 Days of Linux Toys series on Opensource.com; a user there suggested that you might choose mpv as a suitable mplayer replacement, but I'll leave that up to the reader to explore and decide.

Listen to the radio

MPlayer is a versatile multimedia player that will support just about any media format you throw at it. If MPlayer is not already installed, you can probably find it packaged for your distribution. On Fedora, I found it in RPM Fusion (be aware that this is not an "official" repository for Fedora, so exercise caution as you would with any unfamiliar binary source):

$ sudo dnf install mplayer

MPlayer has a slew of command-line options to set depending on your situation. I wanted to listen to the local college radio station here in Raleigh (88.1 WKNC; they're pretty good!), and so after grabbing the streaming URL from their website, all that took to get my radio up and running, no GUI or web player needed, was:

$ mplayer -nocache -afm ffmpeg http://wknc.sma.ncsu.edu:8000/wknchd1.mp3

MPlayer is open source under the GPLv3, and you can find out more about the project and download source code from the project's website.

Visualize your music

If you want to do more than just listen, and get a visual representation of what you're listening to, try cava. Short for "console-based audio visualizer for ALSA" (although it supports more than just ALSA now), cava is a nice MIT-licensed terminal audio visualization tool that's fun to watch. You can install cava much in the same way, through:

$ sudo dnf install mplayer
Cava

Watch a video

Finally, let's double down on our first tool, MPlayer, and add in one more, youtube-dl.

As its name would imply, youtube-dl is a command-line utility for downloading YouTube videos, but it can capture video from a number of other sites as well, and it's a really quite full-featured application with thorough documentation to make video acquisition easy. A note: please don't use youtube-dl in any context that would violate the copyright laws in your jurisdiction.

youtube-dl is licensed under a public domain dedication known as the Unlicense that's similar to Creative Common's CC0. There are some interesting legal opinions out there about where public domain dedication fits into the open source landscape, but it's generally considered compatible with existing open source licenses even by organizations who don't recommend its use.

In its simplest form, we're going to use youtube-dl to grab a video for playback in our terminal. First, install it using a method appropriate for your distribution. For me, in Fedora, it was packaged in my repositories, so installation was as simple as:

$ sudo dnf install youtube-dl

Then, let's grab a video. YouTube allows you to search by license, so today, we're going to take a look at a fireplace video from Gemmy's Videos available under a Creative Commons attribution license. For YouTube videos, you can download with the file ID alone, like this, and we'll specify an output file name as well. I intentionally picked a short video, since long videos can get quite large!

$ youtube-dl pec8P5K4s8c -o fireplace.mp4

You may need to install libcaca for your system if it's not already installed. If you just use MPlayer to launch the video from the command line as-is (mplayer fireplace.mp4), it will play, but in a window all of its own; not exactly what we were going for.

First, I set my libcaca settings to force it to use ncurses as the display driver, keeping the output in my terminal, with:

$ export CACA_DRIVER=ncurses

Then, I zoomed way out in my terminal (the more "pixels", the better), and played the file with the following (forcing the use of libcaca and silencing text output from MPlayer):

$ mplayer -really-quiet -vo caca fireplace.mp4

And, there you go!

Fireplace

 


About the author

Red Hat Certified Engineer. Linux desktop enthusiast. Map/geospatial nerd. Raspberry Pi tinkerer. Data analysis and visualization geek. Occasional Pythonista.

Read full bio
UI_Icon-Red_Hat-Close-A-Black-RGB

Browse by channel

automation icon

Automation

The latest on IT automation for tech, teams, and environments

AI icon

Artificial intelligence

Updates on the platforms that free customers to run AI workloads anywhere

open hybrid cloud icon

Open hybrid cloud

Explore how we build a more flexible future with hybrid cloud

security icon

Security

The latest on how we reduce risks across environments and technologies

edge icon

Edge computing

Updates on the platforms that simplify operations at the edge

Infrastructure icon

Infrastructure

The latest on the world’s leading enterprise Linux platform

application development icon

Applications

Inside our solutions to the toughest application challenges

Original series icon

Original shows

Entertaining stories from the makers and leaders in enterprise tech