Basic mplayer Usage from Command-Line

There are many ways to play media files from the command-line. In fact, in recent weeks past, here at Unixmen we’ve shown you how do it with a couple of different methods.

Today, I’m gonna show you a few basic commands which can be used in a terminal by almost anyone, beginner or advanced. Some users may run into some issues with audio and/or video quality with their own systems’ hardware. But that’s ok because I will also show you how you can get things running smoothly by editing just one file.

The software we are going to use is probably one of the oldest yet most configurable and robust tools available. Mplayer has been around for a long time and is available on a range of platforms.

The easiest way to install mplayer is through your command-line. Just pop open a terminal and enter one of the following:

Ubuntu 13.04

% sudo apt-get install mplayer

Fedora 18

% sudo yum install mplayer

OpenSUSE 12.3

% sudo zypper in mplayer

It’s important to note that mplayer may not be available in the repositories that you have enabled. You may have to enable some extra repositories that contain the mplayer package and dependencies.

For Ubuntu, you will find the newest mplayer package in the Medibuntu repository. In Fedora, you will have to enable the RPM Fusion repositories. And in OpenSUSE, you will find it by enabling the Non-OSS repository.

Once you have enabled the appropriate repository, just go back and enter the command above relevant to your distribution.

Once the installation of mplayer is complete, you are now ready to play a media file. Navigate through your filesystem to where you media files are stored. For the sake of this test, we’ll go to ~/Music:

% cd ~/Music

Use the ls command to list what is in the directory:

% ls
The Offspring – Greatest Hits

Now it helps to cd again in to the directory of files that you wish to play:

% cd The\ Offspring\ -\ Greatest\ Hits/
% ls
01. Foo bar.mp3
02. Foo bar 2.mp3
03. Etc. >>>

Now, we want to play Track 01. That’s easy, we just type the following to get the track playing:

% mplayer 01.\ Foo\ bar.mp3

Your terminal will post some output on the information of the file currently playing. It seems like a lot of information at first, but this is absolutely normal.

After you’ve listened to Track 01, now you want to hear the whole album. Type the following to play all the tracks on the album:

% mplayer *.mp3

Again, you will the usual output and then the track will start playing and continue on for the entirety of the album.

Playing video files is exactly the same. The only difference is once you have typed in the command like this:

% mplayer ~/Movies/Hackers_DVD.XviD.mp4

You will get another X window open and then the video file will begin to play.

Now, how do you control all that media? There’s no interface or buttons. That’s ok, we don’t need them. Remember, everything you are doing here is from the command line.

Here are some important keys to take note of which will help you get started with your media functions:

Q = Quit
P = Pause
Up arrow = Jump forward in file more
Right arrow = Jump forward in file less
Down arrow = Jump back in file more
Left arrow = Jump back in file less
) = Volume up
( = Volume down
M = Volume mute
F = Full screen view
O = On-screen display
V = Toggle subtitles in video

In basic day-to-day usage of mplayer, you really will not need anything more than what I have shown above. It’s best to keep things simple as command-line stuff can get very confusing for beginners and new users. If you want more advanced functions from your keyboard, refer to the mplayer man pages which has everything covered. There is a lot of information in the man pages for mplayer:

% man mplayer

Most of the time you will be abe to play media without any issues on most modern systems. But in the past, I have experienced some issues with playback on some systems. I will show you a few tips that you can do to counter most common playback problems.

First, create a mplayer config file by entering the following:

% touch ~/.mplayer/config

And now to edit the file:

% nano ~/.mplayer/config

Now enter the following text in to the configuration file:

zoom=yes
vo=x11
ao=alsa

The above will solve most people problems.

I hope you enjoy using mplayer from the command-line. Play around with it and have some fun and you come to appreciate its raw power to handle your media.