Revision of mplayer - command line movie and music player - music over ssh from Sun, 03/02/2008 - 00:45

Mplayer is one of most known movie players in Linux, and also in Mac OS, and Windows.

To install it in Debian / Ubuntu run:

sudo aptitude install mplayer

Mplayer has lots of options, and we will explore some of them here, the files format it can play according to its official site are:

MPEG/VOB, AVI, Ogg/OGM, VIVO, ASF/WMA/WMV, QT/MOV/MP4, RealMedia, Matroska, NUT, NuppelVideo, FLI, YUV4MPEG, FILM, RoQ, PVA files, supported by many native, XAnim, and Win32 DLL codecs. You can watch VideoCD, SVCD, DVD, 3ivx, DivX 3/4/5 and even WMV movies..

Playing your music/video files

If you want to play your local files just use this command line

mplayer [filename(s)]

Yes you can put multiple files and they will be played in sequence, you can also use wildcards, lets suppose you have a directory with all Beatles' hits, just go to that directory and enter:

mplayer *

Now if you want to repeat a file multiple times enter

mplayer file1 -loop 2 file2 -loop 1 file3 -loop5

Here you will play file1 2 times file2 one time and file3 5 times, if you want to repeat all files the same amount of times use:

mplayer -loop 5 file1 file2 file3

This will play file1, file2 and file3 5 times, if you use the -loop parameter with 0, you will play the specified files in an infinite loop.

Playing DVDs

To play a standard DVD the syntax is as follow:

mplayer dvd://

[-dvd-device ]

You can also select a specific chapter in a track, the syntax is:

mplayer dvd://

-chapter

If your movie comes with different languages, you can choose which one to play with the -alang option, and then specify the priority of languages check the following example:

mplayer dvd://1 -alang es,en

this will try to play Spanish first, and if it can't it will play English instead.

Also you can choose the subtitles you wish to see, for this use the slang option, check the following example

mplayer dvd://1 -slang es,en

Just like the example above, this will try Spanish first and English then, but this time not for audio, but for subtitles.

Playing VCDs

To play VCDs is as simple as with the DVDs, just enter this on your command line

mplayer vcd://1 -cdrom-device /dev/cdrom

Be sure to specify the right path to your VCD device, which is your CDROM device.

Playing streaming video from the web

You can play videos directly from the web using http, rtsp, ftp or mms protocols just enter the right one in the command line:

mplayer http://your-music-server.com/file.avi

Tips

Playing Surround Multichannel files

mplayer dvd://1 -channels 6

Playing audio files over ssh connection

If you have your favorite music collection at home, and want to listen to it while at work, you can pass it over an ssh connection (of course could be better to take a CD with you)

ssh user@yourhomepc "cat file" | mplayer -

Do not forget to read: http://www.mplayerhq.hu/DOCS/HTML-single/en/MPlayer.html