Multimedia Dynamite

An overview of the awesome power and configurability of MPlayer.

What should the Linux movie player of your dreams do? It should play any movie/video that you throw at it. No questions asked—just play. It should allow seeking and volume control with the keyboard and mouse. It should work with an infrared remote controller and also play television. It should play DVDs and VCDs too. MPlayer can do all of this and much, much more.

MPlayer also is an award-winning, mature, open-source program that still is actively in development. Perhaps one day in the not-too-distant future, support for DVD menus, color subtitles, picture in picture video, MIDI and audio effects plugins like the ones for SoX will be added.

MPlayer is admirably stable for the job it does. However, it does crash under certain circumstances, such as with certain video drivers.

It is a mature application that has no parallel. MEncoder, its companion video encoder program, does a much better job than FFMPEG in transcoding videos, although it is a bit difficult to use and learn.

Now, let's take a look at MPlayer's magic. The following command plays a stream URL after resampling it to 48,000Hz and combining channels into left-right stereo:

$ mplayer -af lavcresample=48000,hrtf 

The following command grabs the same URL stream and dumps it to a file named stream.aac:

$ mplayer -dumpstream -dumpfile stream.aac 
 ↪-softvol -softvol-max 2000 -af 

You can open the stream file from another terminal window with this command:

$ mplayer stream.aac

Then what happens? The first instance of MPlayer continues to dump the network stream to a file and the second plays it for you—time-shifted Internet radio. Cool, eh?

Most of the switches are not necessary to accomplish this, but they show MPlayer's ability to use the Linux command line so elegantly. The -softvol and -softvol-max switches invoke the software volume control feature of MPlayer. It reduces the signal-to-noise ratio, but it can amplify the signal to very high levels.

The volnorm=2:0.5 filter invokes the volume normalization audio filter. The first argument, 2, specifies that several samples are to be used to smooth the volume variations. The 0.5 sets the maximum amplitude to which you want the volume normalized. As you can see, MPlayer provides a high level of customization.

The other options on the command line should not be difficult to decipher.


The following is a command similar to the first one above. In this case, however, you specify a playlist URL. Unlike the above command, this one may not work for you, depending on whether the file happens to be available from the SHOUTcast site when you try it:

$ mplayer -af lavcresample=48000,hrtf -playlist 

The -playlist option is used only with stream URLs that have a .pls extension in the stream.

You can create your own playlists in a variety of ways. Here is one way to do it with the find command:

$ find /home/girish/music -name "*mp3 
 ↪-or -name "*ogg" > ~/playlist.txt

Now, fire up MPlayer with:

$ mplayer -playlist ~/playlist.txt

The following variant shuffles the list and plays songs in random order without repeating songs:

$ mplayer -shuffle -playlist ~/playlist.txt

Naturally, MPlayer is a media player. You don't have to limit yourself to audio files. You could add any MPlayer-playable media file into the mix, including videos, movies, television, radio and, of course, Internet streams.

In addition to this simple line-based playlist format, MPlayer also has excellent support for ASX, M3U and other popular playlist formats.

Special Effects

There is good support for audio effects, and the karaoke effect especially gets interesting with certain songs. It is not perfect, but you can attenuate the voice in a song a great deal. Use the following command to activate karaoke mode:

$ mplayer -af karaoke song.mp3

MPlayer also has a ten-octave band equalizer. The following command ignores the middle frequency bands and amplifies the frequencies around 31.25Hz by 7dB, 62.5Hz by 8dB, 125Hz by 5dB and all of the frequencies around 4, 8 and 16Hz are attenuated by 2dB:

$ mplayer -af equalizer=7:8:5:0:0:0:-2:-2:-2 video.mpg

The following command gives a live effect to playback. Try it with songs that sound monotonous:

$ mplayer -af extrastereo song.mp3

You can issue a command like the following to play the third song five times:

$ mplayer song1.mp3 song2.ogg file.wav -loop 5

If you want to repeat the whole list five times, type the following instead:

$ mplayer { song1.mp3 song2.ogg file.wav } -loop 5

You also can use -loop 0 to play something over and over again.

Additionally, there are many audio effect plugins designed especially for multichannel and 3-D audio. If you want some really advanced audio effects, try the SoX Swiss Army knife. It is another command-line application that excels in professional audio effects.

You can specify multiple audio filters on the command line and they are applied one after another in a chain.

Figure 1. MPlayer Audio/Video Filter Chaining

What if you like a certain audio filter chain and you want to save the resulting audio to a file? The following command saves the output of filtering to the file named filtered.wav rather than playing it:

$ mplayer -ao pcm:file=filtered.wav -channels 4 -af
lavcresample=48000,hrtf,pan=2:1:0:0:0.3:0.5:0.5:0:12 audio.ogg

The lavcresample filter resamples the frequency of audio.ogg to 48,000Hz.

The pan filter is a very powerful and sophisticated filter. It mixes the input audio channels into the specified output channels in various amplitudes.

In this example, we use the -channels switch to specify four input channels. The first argument to pan is 2 to specify two output channels. In the first pair of arguments after that, the 1:0 specifies the amplitude of the first input channel that is fed into the two output channels. It goes into the left channel with an amplification factor of 1. The second input channel goes into the right channel with an amplification factor of 0.3 (0:0.3), and the third input channel is divided equally into both output channels (0.5:0.5). The fourth channel goes into the right channel with an amplification factor of 12.

You can use the following command to re-encode the WAV file to Ogg:

$ oggenc -q 9 filtered.wav 



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

There is good support for

pumarex's picture

There is good support for audio effects

Alaçatı konaklama

alaçatı konaklama's picture

thank you for all

good content

mert2000's picture

thanks admin

hi. thanks for sharing

mini's picture

hi. thanks for sharing


emrah eren's picture

thanks admin


maxi's picture

thanks admin


emrah eren's picture


hi. thanks for sharing. my

comet's picture

hi. thanks for sharing. my friend

is that true?

Anonymous's picture

see... mplayer can't fully display substation alpha subtitles, it messed up the whole karaoke effects

There is good support for

nihat hatipoglu's picture

There is good support for audio effects, and the karaoke effect especially gets interesting with certain songs.

One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix