understandable linux tips, tricks and tutorials

There are some lean movie players on linux (such as codeine), but the ultimate in lean is mplayer. There is of course a gui for mplayer, but if you want to use mplayer as it was intended, you need to run it from the command line.

starting a video or dvd

So how to play a video in mplayer? To play a file, just type mplayer followed by the path to the video file you want to play:

mplayer /path/to/file.avi

If you want to play a dvd, things are a bit different. mplayer doesn’t do dvd menus. So you have to point to the main video file on the dvd. Usually track 1 on the dvd. So type this into a terminal:

mplayer dvd://1

keyboard/mouse control

The best way to control mplayer is with the keyboard. This gives you a whole lot of power and control over the video, without having silly control buttons taking up precious screen real estate. Here are some useful keys/mouse controls:

  • f – toggle fullscreen
  • q – quit
  • space,p – pause
  • j – rotate through subtitiles
  • right/left – skip forward/back 10 seconds
  • up/down – skip forward/back 1 minute
  • pg up/pg down – skip forward/back 10 minutes
  • scroll wheel – skip forward/back
  • <> – skip to next/last file in playlist
  • 9/0 – decrease/increase volume
  • +/- – tweak A/V sync by 100ms
  • T – toggle window on-top

video playback tips

sluggish/jerky dvd playback

If your dvd playback is slow or jerky, add the cache and cache-min options to the command line like this:

mplayer -cache 8912 -cache-min 4 dvd://1

This means that you will have an 8MB cache, which should be plenty for a dvd. It will also fill the cache to 4% before starting, and the buffer should build up from there.

normalise the volume

Adding -af volnorm to the command line will maximise the volume of the audio track, without distorting.

widescreen fullscreen

If you’ve got a widescreen monitor/laptop, you can avoid aspect ratio distortion by setting the command line option -monitoraspect 16:9.

pretty subtitle fonts

You can specify the true-type font used for subtitles by copying a true-type font to ~/.mplayer/subfont.ttf. For example if you want to use bitstream vera sans, copy bitstream vera sans like this:

cp /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf ~/.mplayer/subfont.ttf

subtitle font size

If your subtitle font is too big/small, play with the -subfont-text-scale option. For example:

mplayer -subfont-text-scale 3 /path/to/file.avi

video output

You can change the video output to those which are supported by your video with the -vo option. To see what is supported, type:

mplayer -vo help

The most useful options will be xv, x11, gl and gl2. The best option is usually xv, however, sometimes this gets a bit funky with xgl/aiglx/beryl/compiz. If that happens, try x11. Bare in mind, x11 won’t allow you to change the size of the video, unless you add the -zoom option:

mplayer -vo x11 -zoom /path/to/file.avi

seeking un-seekable files

If you come across an avi file that won’t seek when you use the left/right/up/down keys, you can add the -idx option to make it seekable.

mplayer config

Instead of adding options willy nilly to the command line, you can set most of this stuff up in a config file, which mplayer uses as its default settings. Bear in mind that the config file options can be overridden by command line options. The config file is stored at ~/.mplayer/config. This is a reasonably generic config file that should work for most people:

#General setup
ao="alsa" #audio out
mixer-channel="Master"
srate=48000
really-quiet="1" #Very very little console output
vo="xv" #video out
zoom="1" #Allow sofware scaling if you use x11 for vo from the commandline
aid="1" #audio channel
sid="0" #subtitle set
#Display
double="yes" #double buffering(recommended for subtitles)
monitoraspect="16:9" #Use for a widescreen laptop so keeps 4:3 content from stretching
framedrop="1" # For slow machines
hardframedrop="0" #Make sure hard frame drop is off but can turn on easily now
#subtitle code
#set this if you haven't copied your preferred font to ~/.mplayer/subfont.ttf
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf
ffactor="10" #black outline
sub-bg-alpha="0" #background color ala closed captions
sub-bg-color="0" #black to white
subfont-text-scale="3.7" #truetype font scaling
subfont-blur="1" #Slight blur
#This sets the postprocessing into overdrive using all possible spare cpu cycles to make the movie look better
autoq=100
vf=pp=de,hqdn3d
subpos="90" #By default subtitles are too low
subalign="2"
#turns off xscreen saver...sometimes
stop-xscreensaver="yes"
#Some extra stuff you may want to try.  Remove "#'s" to activate
#Fix A/V sync problems on files with bad MP3 VBR audio
#mc="1"
#autosync="10"
#delay="0.5"

wierd stuff

If you want to play movies in ascii art, check out this article.

6 Comments
  1. Hello.
    I’ve compiled and installed mplayer from the source.
    I have a question — what option and what exactly I have to write in config file of mplayer that it started from the last point of viewed film when playing the video file?

  2. hey i just want to pause and stop the mplayer….i am using a qt application…wen i pressed on the stop and pause button i want the respective action….i know the processs id of mplayer….is ant command to stop and pause the mplayer using the pid of mplayer

    • I’m not sure I understand. If you want to pause, press spacebar. If you want to stop, press q. I’m not sure what relevance qt has.

  3. 1rs, i want to thanks for make it possible to play movies (any coding mode) on n900!

    what i must setup to change the encoding subtitles? you know….central europian, greek…etc.?

Leave a Reply

Site last updated October 20, 2012 @ 12:53 pm; This content last updated September 12, 2012 @ 3:19 am