Science and technology

Watch YouTube movies on the Linux terminal

We’re nearly to the top of our 24-day-long Linux command-line toys creation calendar. Hopefully, you have been following alongside, but when not, begin again at the beginning and work your approach by. You’ll discover loads of video games, diversions, and oddities in your Linux terminal.

And whereas you could have seen some toys from our calendar earlier than, we hope there’s no less than one new factor for everybody.

Today we will double-down on yesterday’s toy, MPlayer, and add in yet another, youtube-dl.

As its title would suggest, youtube-dl is a command-line utility for downloading YouTube movies, however it will possibly seize video from a variety of different websites as effectively, and it is a actually fairly full-featured software with thorough documentation to make video acquisition straightforward. A word: please do not use youtube-dl in any context that will violate the copyright legal guidelines in your jurisdiction.

youtube-dl is licensed below a public area dedication referred to as the Unlicense that is much like Creative Common’s CC0. There are some fascinating legal opinions on the market about the place public area dedication matches into the open supply panorama, nevertheless it’s usually thought of appropriate with current open supply licenses even by organizations who do not suggest its use.

In its easiest kind, we will use youtube-dl to seize a video for playback in our terminal. First, install it utilizing a technique applicable in your distribution. For me, in Fedora, it was packaged in my repositories, so set up was so simple as:

$ sudo dnf set up youtube-dl

Then, let’s seize a video. YouTube lets you search by license, so at the moment, we’re going to check out a hearth video from Gemmy’s Videos accessible below a Creative Commons attribution license. For YouTube movies, you’ll be able to obtain with the file ID alone, like this, and we’ll specify an output file title as effectively. I deliberately picked a brief video, since lengthy movies can get fairly giant!

$ youtube-dl pec8P5K4s8c -o hearth.mp4

If you did not set up MPlayer yesterday, go forward and try this, and chances are you’ll want to put in libcaca in your system as effectively for those who didn’t set up it beforehand. If you simply use MPlayer to launch the video from the command line as-is ($ mplayer hearth.webm), it’ll play, however in a window all of its personal; not precisely what we had been going for.

First, I set my libcaca settings to drive it to make use of ncurses because the show driver, maintaining the output in my terminal, with:

$ export CACA_DRIVER=ncurses

Then, I zoomed approach out in my terminal (the extra “pixels”, the higher), and performed the file with the next (forcing using libcaca and silencing textual content output from MPlayer):

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

And, there you go!

Do you’ve gotten a favourite command-line toy that we must always have included? It’s a bit late to submit a suggestion for this yr, however we would nonetheless like to characteristic some cool command-line toys within the new yr. Let me know within the feedback beneath, and I am going to test it out. And let me know what you considered at the moment’s amusement.

Be positive to take a look at yesterday’s toy, Listen to the radio at the Linux terminal, and are available again tomorrow for an additional!

Most Popular

To Top