Play Youtube Audio from Terminal

Hi,

do you know of a command line tool, that plays YouTube videos in the terminal? I does not have to show the YouTube-video. In fact I dont even want the original video.
But on top, a kind of graphical (equalizer, waveform - like) visualization would be cool, but not necessary…

I would be glad for any advice.

Kind regards

Pragomer

Getting audio from a YouTube video:

# Get whichever format is best
youtube-dl --extract-audio --audio-format best <URL>

# Get an mp3
youtube-dl --extract-audio --audio-format mp3 <URL>

I don’t know of any terminal players which encorporate a visualizer though there’s projects that do the equalizer by itself. An easy way to combine the two in one window would be using screen or tmux.

1 Like

ffplay is what you want to use. It has several options for the display of the audio spectrum. Just pipe the output of the youtube-dl into ffplay: (It takes a few seconds to get enough data to start the playback)

youtube-dl -f bestaudio https://www.youtube.com/watch?v=ZzDOgJ29aXw -o - 2>/dev/null | ffplay -autoexit -i - &>/dev/null

Learn more about ffplay here:

https://ffmpeg.org/ffplay-all.html

2 Likes

I don’t know that this has the visualzation you want, but GitHub - mps-youtube/mps-youtube: Terminal based YouTube player and downloader

You could probably pipe it into something else that displays your audio out in that format in the CLI

I think mps is almost non functional nowadays. There is another terminal tool (also comes with a minimal GUI) called youplay.

Also, mpv is capable of playing Youtube videos from the command line using youtube-dl applying the option --no-video.