Play videos from the Linux ter­mi­nal

John Knight at­tempts to woo scared mul­ti­me­dia users into try­ing the ter­mi­nal with MPlayer’s amaz­ing ca­pa­bil­i­ties.

APC Australia - - Contents -

MPlayer has a GUI, so why on earth would you use it via com­mand line? Sim­ple: com­bin­ing MPlayer with the ter­mi­nal gives you power in ways a GUI pro­gram just can’t. So much like your mum ex­plain­ing why you need to eat your veg­eta­bles (un­til you even­tu­ally re­lent!), here’s to do­ing things the hard way.

Us­ing MPlayer with­out any fancy tweaks or op­tions is easy. The com­mand with all de­faults sim­ply looks like this:

$ mplayer thi­sisanex­am­ple. avi

If you’ve not used MPlayer be­fore, you need to re­alise that MPlayer is en­tirely key­board-driven. Ini­tially, this seems odd, but there’s method to the mad­ness: flick­ing through videos is much faster than a reg­u­lar mousedriven GUI, and if you know your place in the movie, you can make a few but­ton taps to get within a few sec­onds of where you want to be.

To get started, ‘F’ is for Fullscreen, ‘Space’ is for pause, ‘Q’ is for quit, and the ar­row keys fast for­ward and rewind in in­ter­vals of ei­ther one minute (Up and Down), or ten sec­onds (Left and Right). ‘Page Up’ and ‘Page Down’ seek in ten-minute in­ter­vals, while vol­ume is con­trolled by the * and / keys on your key­pad. And that’s about all you need to get go­ing.

MPlayer’s key­board-driven in­ter­face feels weird at first, but its whole setup and aes­thetic leaves you feel­ing like you’re on some kind of tac­tile, be­spoke ma­chine — like a video pro­duc­tion sta­tion or a se­cu­rity mon­i­tor, rather than just us­ing an­other generic video ap­pli­ca­tion on a dull PC. Nav­i­gat­ing videos this way is im­mensely sat­is­fy­ing and ex­tremely fast.

At this point, it’s worth in­tro­duc­ing the ‘O’ but­ton, which en­ables the On Screen Dis­play (or OSD for short) with that per­fect ma­chine font that looks like some­thing from a ’90s Be­ta­max stu­dio player — fur­ther re­in­forc­ing that feel­ing of us­ing a proper cus­tom ma­chine. Press­ing ‘O’ once will en­able cer­tain OSD el­e­ments, such as a progress bar that ac­ti­vates when you seek. A sec­ond press will bring up a sim­ple timer, a third will show the timer against the whole length of the track, and a fourth press will turn the OSD back off again.

Let’s look at some other kinds of me­dia while we fur­ther ex­am­ine the con­trols. Play­ing DVDs is a dod­dle — though per­haps an odd one. With­out menus, you need to man­u­ally wade through the DVD ti­tle num­bers in search of what you want. Start­ing with ti­tle 1, the com­mand sim­ply looks like this: $ mplayer dvd://1 Try­ing each ti­tle in­di­vid­u­ally sounds worse than it is: a movie will usu­ally be placed on ei­ther ti­tle 1 or ti­tle 2, so try ti­tle 2 in­stead if you just get an an­noy­ing warn­ing screen. Extra fea­tures will gen­er­ally be stored in the higher num­bers.

This might sound like more ef­fort than it’s worth, but if you think about all the menus and warn­ing screens you usu­ally need to wade through on a DVD, the MPlayer way usu­ally has you

into the movie within a few sec­onds (and is it re­ally that much labour try­ing a 2 if 1 doesn’t work?). And it’s a great way to quickly find any Easter eggs!

Once it’s play­ing, you can tweak your movie on the fly with some im­pres­sive video con­trols. Keys 1 and 2 ad­just con­trast, 3 and 4 the bright­ness, 5 and 6 the hue, and 7 and 8 con­trol colour sat­u­ra­tion. And in case you’re watch­ing a for­eign film or need cap­tions, ‘ V’ turns on the sub­ti­tle vis­i­bil­ity, and ‘J’ cy­cles through the avail­able lan­guages.

Strict con­sole users with­out ‘X’ will be pleased to know MPlayer also works as a CD player, and is easy to use as well — seek­ing with the ar­row keys is a great way to nav­i­gate a CD. To play a CD from the start, sim­ply en­ter: $ mplayer cdda:// To spec­ify a track, just add the track num­ber to the end of the com­mand: $ mplayer cdda://6

NITTY GRITTY

That’s all well and good, but how is this any more use­ful than a GUI? Well, MPlayer comes into its own when it in­ter­acts with the Linux shell in gen­eral: pipes, script­ing, info dumps, that sort of thing.

Let’s start with some­thing ba­sic. Say you want to play all the video files in a folder. That’s as sim­ple as en­ter­ing: $ mplayer * If you have just run this com­mand, the En­ter key will close the cur­rent video should you want to move on to the next one.

Per­haps you have an enor­mous li­brary of movies or mu­sic videos and are in search of one video in par­tic­u­lar, but all you can re­mem­ber is the first letter (let’s say it starts with a ‘ W’ for this ex­am­ple). Re­mem­ber­ing that Linux is case-sen­si­tive, you could play all videos start­ing with W in ei­ther case by en­ter­ing: $ mplayer W* w* If you col­lect and store mu­sic videos off­line, you prob­a­bly have an enor­mous folder full of ran­domly named film clips. If you want to jump straight to some videos of a par­tic­u­lar band with­out hav­ing to sort through hun­dreds of files, the ter­mi­nal is very help­ful.

Let’s say you want to play all lo­cally stored videos from the band Au­dioslave. You have no idea whether files will start with up­per or lower case, and there is a de­cent chance files may not even start with the band’s name (per­haps start­ing with some num­bers, for in­stance). You can get around this by sim­ply search­ing for the mid­dle of the word, and plac­ing an as­terisk on ei­ther side. By for­get­ting the A at the start, this com­mand will now play any Au­dioslave videos, re­gard­less of how the file­name starts or ends: $ mplayer *udioslave*

GET­TING ELAB­O­RATE

Of course, a ter­mi­nal col­umn wouldn’t be a ter­mi­nal col­umn with­out a good old pipe, and MPlayer is no ex­cep­tion! For the unini­ti­ated, pipes al­low you to con­nect one pro­gram — or even many — to an­other in a chained se­quence, con­nect­ing one pro­gram’s out­put to the next pro­gram’s in­put.

Of course, MPlayer can stream a file di­rectly from its URL, but we wish to demon­strate its pi­peable func­tion­al­ity. So we’ve cho­sen a sim­ple ex­am­ple, pip­ing the out­put of down­load pro­gram wget to the in­put of MPlayer. The syn­tax is slightly baf­fling: the -O switch ob­vi­ously means ‘out­put’, but those phan­tom hy­phens are a bit odd! Ei­ther way, here we are stream­ing a pub­lic test clip from the Cinel­erra web­site, show­ing some footage from Ital­ian tele­vi­sion:

$ wget https://cinel­erra-cv. org/footage/rassegna2.avi -O - | mplayer -

MPlayer is also handy for dump­ing the file you want to stream to some­thing stored lo­cally. We’ll for­get the pipe for a mo­ment and just stream the file di­rectly, but here we are ‘dump­ing’ the Cinel­erra test video to a stored lo­cal file:

$ mplayer https://cinel­er­racv.org/footage/rassegna2.avi -dump­stream -dump­file dumped. avi

Note the URL comes im­me­di­ately af­ter the com­mand; the -dump­stream and -dump­file switches tell MPlayer that this is a stream­ing in­ter­net file to be saved lo­cally; and fi­nally the file­name is spec­i­fied for where you wish to ‘dump’ it. This func­tion­al­ity is par­tic­u­larly use­ful for old stream­ing con­tent from the late ’90s and 2000s (par­tic­u­larly archived ra­dio pro­grammes), and it’s worth not­ing the doc­u­men­ta­tion uses the old .asf file for­mat as an ex­am­ple! So yes, MPlayer has a slightly odd way of do­ing things, and you’re still likely to pre­fer a GUI pro­gram. But hope­fully we’ve shown you some things you didn’t know the ter­mi­nal was ca­pa­ble of, and per­haps it hasn’t been so hard af­ter all?

MPlayer’s ex­ten­sive his­tory means all sorts of in­ter­est­ing mod­i­fi­ca­tions and add-ons have been made for it. Here is a video run­ning through a ‘ma­trixview’ fil­ter.

MPlayer can be aug­mented by com­mand line tools like pipes. Here MPlayer is di­rectly stream­ing a video while it’s be­ing grabbed on the fly by ‘ wget’.

Newspapers in English

Newspapers from Australia

© PressReader. All rights reserved.