Multimedia Dynamite

An overview of the awesome power and configurability of MPlayer.
Custom Subtitles

Not surprisingly, MPlayer understands close to 12 subtitle formats, and it has its own MPSub format too. The options for subtitle display are the richest I have seen. You can display subtitles in any size, any position on the video, move them dynamically with the keyboard, adjust the delay, change the transparency, format them into multiple lines and so on.

Here is the most basic usage of the file subtitles.txt:

FORMAT=TIME
# first number  : wait this much after 
# previous subtitle disappeared
# second number : display the current 
# subtitle for this many seconds

2 3
What is going on?

4 3
How are you doing?

8 3
You are wrong!

0 3
A long long, time ago...
in a galaxy far away...

0 3
Naboo was under an attack.

0 200
I don't understand this.

Tell MPlayer to use this file with a command like this:

$ mplayer -sub subtitles.txt 
 ↪-font ~/.ttffonts/Verdana.ttf video.avi

This next command dumps the subtitles file into the srt format into the file dumpsrt.sub in the current directory:

$ mplayer -sub subtitles.txt video.avi -dumpsrtsub

You can take a quick look at all subtitles in the file by pressing the Y and G keys. Of course, you can specify multiple subtitle files, and you can switch between them.

Create Screenshots

Want to take screenshots with MPlayer? It's easy. Here's a sample command to use when you start to play a video:

$ mplayer -vf screenshot video.avi

Press S when you want to take a screenshot. If you want a screenshot every five seconds, try the following command:

$ mplayer -vo png -vf screenshot -sstep 5 video.avi

What if you want to take a screenshot of every frame? Set MPlayer to accept slave commands with a FIFO, and type these commands:

$ mkfifo /tmp/fifo
$ mplayer -input file:/tmp/fifo video.mpg
$ echo 'screenshot 1' > /tmp/fifo

Toggle the screenshot process with the following command while the video is playing:

$ echo 'screenshot 1' > /tmp/fifo

You might want to use the -vf spp,scale=1024:768 switch to get full-screen screenshots.

Even More Power

There's much more MPlayer can do. You can encode image files into a video and extract frames into image files with MPlayer. You also can watch analog television with the tv:// option and watch DVB channels with the dvb:// option. It supports a wide variety of streaming protocols, including RTP, RTSP, MMS, SDP and LIVE5555 streaming.

Discover the Power Yourself

The following command lists the available filters:

$ mplayer -af help

The man page and MPlayer's HTML documentation have more thorough descriptions of its options. Typing:

$ mplayer -vo help

lists the compiled video output drivers.

You can play an arbitrary audio file with the video using:

$ mplayer video.mpg -audiofile audio.aac

Of course, MPlayer can play a wide variety of audio and video media files. The following commands list them:

$ mplayer -vo help

$ mplayer -ao help

Try using the -audio-demuxer switch along with -rawaudio.

I hope this gets you started in discovering the awesome power of MPlayer. Enjoy your multimedia experience!

Girish Venkatachalam is an open-source hacker deeply interested in UNIX. In his free time, he likes to cook vegetarian dishes and actually eat them. He can be contacted at girish1729@gmail.com.

______________________

Comments

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

new

emrah eren's picture

thanks admin

no

maxi's picture

thanks admin

hello

emrah eren's picture

thanks

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.

Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

Upcoming Webinar
8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
11am CDT, April 29th
Moderated by Linux Journal Contributor Mike Diehl

Sign up now

Sponsored by Skybot