This page was created from the Ubuntu Forums guide: Top 10 Tricks and Tips for the svn MPlayer, where support is still available for this wiki page. Thanks to the author of this guide for his kind permission to use the material on this page!

Introduction

I have been writing guides for the installation of the svn MPlayer under Ubuntu Linux for sometime now but for this wiki page I would like to move away from installation issues and deal with usage of this amazing program. Documented here are what I have previously described as 'Top 10 Tricks and Tips for the svn MPlayer', they are a collection of the 10 best tips and tricks that I have found either useful or fascinating in my dealings with the svn MPlayer.

Tip 1: Using 'scaletempo'

The audio filter 'scaletempo' has many, many options but I am pretty sure that most will use it to playback their favourite media at different speed but with the same pitch. So to play your media file at half-speed and scale the sound to the same speed, without altering the pitch, you would run:

mplayer -af scaletempo -speed 0.5 my_file.mp4

The special magic with this is that you can decrease and increase playback speed while this in progress by using the default '{' and '}' keys and the sound pitch will alter to match the new speed. There are many options available for this audio filter, all carefully documented in the man pages, but I will admit that for my own purposes I have usually only used the syntax demonstrated above.

Tip 2: Play from archives

MPlayer can play from stdin thus opening the way to using any program as input that can output media to stdout. One popular usage is to play directly compressed media files directly from rar archives:

unrar p -inul myarchive.rar | mplayer -cache 2048 -

This technique can be duplicated with tarred files:

tar xvf test.tar.gz -O | mplayer -cache 2048 -

and finally with zip files:

unzip -p test.zip | mplayer -cache 2048 -

Thus the archived media file is opened with MPlayer without the archive being formally opened and a new file being created. Economical as well as being more than a little cool!

Tip 3: Convert anything to wav

One of the biggest drawcards of MPlayer is that it will play almost any media file available. But a very valuable adjunct to this ability is MPlayer's capacity to then output audio files in wav format:

mplayer input.wma -vc null -vo null -ao pcm:fast:waveheader:file=output.wav

I have used 'input.wma' here as an example but you can place any audio or video file in its place and MPlayer will ignore the video and convert the sound to wav, ready for conversion to whatever format takes your fancy! Simple, but very, very effective.

Tip 4: Using cropdetect

I have read manuals describing in enormous detail how to calculate cropping parameters to enable the removal of black bands from DVD movies with usually only marginal comprehension and chaotic results on encoding. But the good news for me, and perhaps for you also, is that MPlayer possesses an excellent video filter that does all of the work and all of the maths. The best way to use this filter is to start a little way into the movie as I illustrate here using the greatest movie of all time, the Matrix:

mplayer -vf cropdetect=round:16 -ss 10:00 dvd://

The terminal output will show the cropping parameters and in the case of the Matrix DVD these figures are -vf crop=720:416:0:80. There is yet another filter that can be used to test these settings:

mplayer -vf rectangle=720:416:0:80 -ss 20:00 dvd://

I will admit to being blown away the first time I saw the rectangle filter at work, how cool is it! If you are happy with these parameters they can be used to encode the movie with MEncoder or simply for playback with MPlayer:

mplayer -vf crop=720:416:0:80,scale -zoom -xy 800 dvd://

I have thrown in a little resizing magic as well, not entirely necessary but it is perhaps a little too easy to get intoxicated with the commandline!

Tip 5: Taking screenshots

MPlayer comes with a very nice and easy to use video filter that allows taking single or multiple screenshots. The syntax is simple:

mplayer -vf screenshot my_file.mp4

Simply pressing the 's' key takes a single screenshot in png format in the working directory. If you wish to take a series of screenshots you can press the 'S' key and MPlayer will keep taking screenshots until the 'S' key is pressed again. However if this is a little too straightforward for you MPlayer also can also output images in a slightly different way that has a few more options:

mplayer -nosound -frames 5 -vo png:z=9 my_file.mp4

This will output the first 5 frames of the media file in high quality png format into the working directory. Similar screenshots can be taken by using jpeg, gif89a, targa and pnm as '-vo'. How incredibly cool is that!

Tip 6: Getting a little wacky

Well, it is time to move away from all this serious commandline stuff and experience just a little wackiness by playing a media file converted to ascii art:

mplayer -vo aa -monitorpixelaspect 0.5 myfile.mp4

This should be enough to play around with but if you really want to go to town with this crazy little MPlayer option you can see the many options available as follows:

mplayer -vo aa:help -frames 0 myfile.mp4

Now I counted about 50 options there that I have not ever really experimented with, perhaps one rainy day I shall return to this! But there is an ever wackier opion here which is to view your media file in coloured ascii:

mplayer -vo caca myfile.mp4

Apparently if you squint at this display it is a little easier to actually see, but I am really not so sure about this! Perhaps slightly more useful is the ability to play videos without even having X loaded, using the Linux framebuffer (fbdev). I illustrate below the method of getting the video to play on a true console, in the middle of the screen:

mplayer -vo fbdev -screenw 800 -screenh 600 -geometry 50%:50% myfile.mp4

Don't forget to alter the -screenw and -screenh options to match your own screen and perhaps investigate the -geometry options to place the video wherever you wish.

Tip 7: Playing audio cds

At a time when almost everybody is getting very excited about the svn MPlayer finally getting decent access to DVD movie menus I would like to mention that MPlayer does an excellent job playing audio cds. The simplest way to play the entire music cd is:

mplayer -cache 2048 cdda://

But of course where would the fun be in using the 'simplest' way! A common problem with music cd playback in this fashion is that MPlayer is very sensitive to the size of the cache so it is my usual practice to tell MPlayer to allow the cache to fill to say 80% before playback, up from the default of 4%. Also a slight change in syntax allows a CDDB query to be performed at the same time:

mplayer -cache 2048 -cache-min 80 cddb://

As always there are many more options that will allow manipulation of this playback but I will admit again that my needs are fairly modest and the above syntax is as far as I normally go.

Tip 8: Using playlists

There is no great mystery to playlists, they are simply lists of files with each file on its own line. It is easy enough to create one and run it with MPlayer and I shall demonstrate here how I create a playlist of my own Ogg Vorbis files:

find $HOME/music -name '*.ogg' > $HOME/ogg.pls

One playlist created and ready to go, now to play it with MPlayer using a shuffle option to allow random play and a loop option to play the whole thing through twice:

mplayer -loop 2 -shuffle -playlist $HOME/ogg.pls

The playlist can also be navigated backwards and forwards by using the '<' and '>' keys respectively. How easy is that to accomplish and what fine control you have over every aspect of the whole thing!

Tip 9: Using DVD menus

There is vast excitement at the moment as the svn MPlayer has finally received working access to DVD menus. There is still some work to go but the structure is definitely in place and to have a quick look at the work in progress the syntax is as simple as:

mplayer -mouse-movements -nocache dvdnav://

(Although I believe '-nocache' is no longer necessary for dvdnav I include it here to avoid confusion.) Of course if this too much to remember you can simply place this, as you can place almost any setting, in your $HOME/.mplayer/config file. A slight variation of the settings seen in the man pages would leave this as:

[protocol.dvdnav]
profile-desc="Profile for reading DVD menus"
mouse-movements=yes
nocache=yes

which reduces the commandline to a much more manageable:

mplayer dvdnav://

Having done this you can make your profile as complex as you wish and still load it with this single command. You can keep track of all of your profiles as follows:

$ mplayer -profile help
Available profiles:
        protocol.dvdnav Profile for reading DVD menus

If you prefer not to modify core MPlayer elements in this way you can simply label the profile something like [menus] and then load it from the commandline as follows:

mplayer -profile menus dvdnav://

and I will admit that this is my personal preference, but I will leave you to make your own choices here.

Tip 10: TOOLS & DOCS/tech

A final tip that reveals the hidden treasure of scripts and documentation available in the svn MPlayer source that is so often neglected. In the TOOLS directory is a small collection of scripts and I list a few of them below to whet your appetite:

  • midentify.sh Identifies files using MPlayer but cleans up the output substantially.

  • wma2ogg.pl Converts WMA files to Ogg or MP3.

  • mencvcd.sh Converts DVD (or anything else that MPlayer plays) to (S)VCD.

  • aconvert.sh A hack to allow MEncoder to read respectively encode from audio only files.

  • qepdvcd.sh converter from any supported format to VCD/SVCD PAL/NTSC.

and many more. Well worth a read as well are the many documents scattered in another subdirectory DOCS/tech and again I give a small sample here of some of those available:

  • encoding-tips.txt A small collection of 'words of wisdom' concerning best encoding practice.

  • svn-howto.txt Details of using svn for those with write access.

  • patches.txt How to successfully submit a patch of your own to the MPlayer devs.

  • codecs.conf.txt Understanding MPlayer's etc/codecs.conf File.

  • transaltions.txt How to become a translator for MPlayer.

And then of course there are the html docs that can be generated from DOCS/xml, but I have reached the end of this guide now so perhaps I will deal with these in another guide...

And in conclusion...

I have had an immensely good time writing this guide as it has allowed me to explore in some depth some of the many aspects of MPlayer that I have perhaps only glossed over in the past. I hope that the guide will allow others to gain a greater knowledge of this great program while at the same time I am ready to learn from the comments of those who have better or different ideas to contribute. And remember: "Have Fun!!".


CategorySoftware

MPlayerTips (last edited 2012-05-13 08:52:18 by mc3man)