Terminal Multimedia........................
John Knight attempts to woo scared multimedia users into trying the terminal with MPlayer’s amazing capabilities
John Knight attempts to woo scared multimedia users into trying the terminal with MPlayer’s amazing capabilities.
MPlayer has a GUI, so why on earth would you use it by command line? Simple: combining MPlayer with the terminal gives you power in ways a GUI program just can’t. So much like your mum explaining why you need to eat your vegetables (until you eventually relent!), here’s to doing things the hard way.
Using MPlayer without any fancy tweaks or options is easy. The command with all defaults simply looks like this: $ mplayer thisisanexample.avi
If you’ve not used MPlayer before, you need to realise that MPlayer is entirely keyboard-driven. Initially this seems odd, but there’s method to the madness: flicking through videos is much faster than a regular mouse-driven GUI, and if you know your place in the movie, you can make a few button taps to get within a few seconds of where you want to be.
To get started, F is for Fullscreen, Space is for pause, Q is for quit, and the arrow keys fast forward and rewind in intervals of either one minute (Up and Down), or ten seconds (Left and Right). Page Up and Page Down seek in ten-minute intervals, while volume is controlled by the * and / keys on your keypad. And that’s about all you need to get going.
MPlayer’s keyboard-driven interface feels weird at first, but its whole setup and aesthetic leaves you feeling like you’re on some kind of tactile, bespoke machine – like a video production station or a security monitor, rather than just using another generic video application on a dull PC. Navigating videos this way is immensely satisfying and extremely fast.
At this point it’s worth introducing the O button, which enables the On Screen Display (or OSD for short) with that perfect machine font that looks like something from a ’90s Betamax studio player – further reinforcing that feeling of using a proper custom machine. Pressing O once will enable certain OSD elements, such as a progress bar that activates when you seek. A second press will bring up a simple 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 media while we further examine the controls. Playing DVDs is a doddle – though perhaps an odd one. Without menus, you need to manually wade through the DVD title numbers in search of what you want. Starting with title 1, the command simply looks like this: $ mplayer dvd://1
Trying each title individually sounds worse than it is: a movie will usually be placed on either title 1 or title 2, so try title 2 instead if you just get an annoying warning screen. Extra features will generally be stored in the higher numbers.
This might sound like more effort than it’s worth, but if you think about all the menus and warning screens you usually need to wade through on a DVD, the MPlayer way usually has you into the movie within a few seconds (and is it really that much labour trying a 2 if 1 doesn’t work?). And it’s a great way to quickly find any Easter eggs!
Once it’s playing, you can tweak your movie on the fly with some impressive video controls. Keys 1 and 2 adjust contrast, 3 and 4 the brightness, 5 and 6 the hue, and 7 and 8 control colour saturation. And in case you’re watching a foreign film
or need captions, V turns on the subtitle visibility, and J cycles through the available languages. Strict console users without X will be pleased to know
MPlayer also works as a CD player, and is easy to use as well – seeking with the arrow keys is a great way to navigate a CD. To play a CD from the start, simply enter: $ mplayer cdda:// To specify a track, just add the track number to the end of the command: $ mplayer cdda://6
Nitty gritty
That’s all well and good, but how is this any more useful than a GUI? Well, MPlayer comes into its own when it interacts with the Linux shell in general: pipes, scripting, info dumps, that sort of thing.
Let’s start with something basic. Say you want to play all the video files in a folder. That’s as simple as entering: $ mplayer *
If you have just run this command, the Enter key will close the current video should you want to move onto the next one.
Perhaps you have an enormous library of movies or music videos and are in search of one video in particular, but all you can remember is the first letter (let’s say it starts with a W for this example). Remembering that Linux is case-sensitive, you could play all videos starting with W in either case by entering: $ mplayer W* w*
If you collect and store music videos offline, you probably have an enormous folder full of randomly named film clips. If you want to jump straight to some videos of a particular band without having to sort through hundreds of files, the terminal is very helpful.
Let’s say you want to play all locally stored videos from the band Audioslave. You have no idea whether files will start with upper or lower case, and there is a decent chance files may not even start with the band’s name (perhaps starting with some numbers, for instance). You can get around this by simply searching for the middle of the word, and placing an asterisk on either side. By forgetting the A at the start, this command will now play any Audioslave videos, regardless of how the filename starts or ends: $ mplayer *udioslave*
Getting elaborate
Of course a terminal column wouldn’t be a terminal column without a good old pipe, and MPlayer is no exception! For the
uninitiated, pipes allow you to connect one program – or even many – to another in a chained sequence, connecting one program’s output to the next program’s input.
Of course, MPlayer can stream a file directly from its URL, but we wish to demonstrate its pipeable functionality. So we’ve chosen a simple example, piping the output of download program wget to the input of MPlayer. The syntax is slightly baffling: the -O switch obviously means “output”, but those phantom hyphens are a bit odd! Either way, here we are streaming a public test clip from the Cinelerra website, showing some footage from Italian television: $ wget https://cinelerra-cv.org/footage/rassegna2.avi -O - | mplayer -
MPlayer is also handy for dumping the file you want to stream to something stored locally. We’ll forget the pipe for a moment and just stream the file directly, but here we are ‘dumping’ the Cinelerra test video to a stored local file: $ mplayer https://cinelerra-cv.org/footage/rassegna2.avi -dumpstream -dumpfile dumped.avi
Note the URL comes immediately after the command; the -dumpstream and -dumpfile switches tell MPlayer that this is a streaming internet file to be saved locally; and finally the filename is specified for where you wish to ‘dump’ it. This functionality is particularly useful for old streaming content from the late ’90s and 2000s (particularly archived radio programmes), and it’s worth noting the documentation uses the old .asf file format as an example!
So yes, we know MPlayer has a slightly odd way of doing things, and yes, you’re still likely to prefer a GUI program. But hopefully we’ve shown you some things you didn’t know the terminal was capable of, and perhaps it hasn’t been so hard after all?