2.7. Subtitles and OSD
Prev | Chapter 2. Installation | Next

## 2.7. Subtitles and OSD

MPlayer can display subtitles along with movie files. Currently the following formats are supported:

- VOBsub

- OGM

- CC (closed caption)

- MicroDVD

- SubRip

- SubViewer

- Sami

- VPlayer

- RT

- SSA

- PJS (Phoenix Japanimation Society)

- MPsub

- AQTitle

- JACOsub

MPlayer can dump the previously listed subtitle formats (except the three first) into the following destination formats, with the given options:

- MPsub: `-dumpmpsub`

- SubRip: `-dumpsrtsub`

- MicroDVD: `-dumpmicrodvdsub`

- JACOsub: `-dumpjacosub`

- Sami: `-dumpsami`

MEncoder can dump DVD subtitles into VOBsub format.

The command line options differ slightly for the different formats:

VOBsub subtitles. VOBsub subtitles consist of a big (some megabytes) `.SUB` file, and optional `.IDX` and/or `.IFO` files. If you have files like ``sample.sub``, ``sample.ifo`` (optional), ``sample.idx`` - you have to pass MPlayer the `-vobsub sample [-vobsubid `id`]` options (full path optional). The `-vobsubid` option is like `-sid` for DVDs, you can choose between subtitle tracks (languages) with it. In case that `-vobsubid` is omitted, MPLayer will try to use the languages given by the `-slang` option and fall back to the `langidx` in the `.IDX` file to set the subtitle language. If it fails, there will be no subtitles.

Other subtitles. The other formats consist of a single text file containing timing, placement and text information. Usage: If you have a file like ``sample.txt``, you have to pass the option `-sub `sample.txt`` (full path optional).

Adjusting subtitle timing and placement:

`-subdelay `sec``
  Delays subtitles by ``sec`` seconds. Can be negative. The value is added to movie's time position counter.
`-subfps `RATE``
  Specify frame/sec rate of subtitle file (float number).
`-subpos `0-100``
  Specify the position of subtitles.

If you experience a growing delay between the movie and the subtitles when using a MicroDVD subtitle file, most likely the framerate of the movie and the subtitle file are different. Please note that the MicroDVD subtitle format uses absolute frame numbers for its timing, but there is no fps information in it, and therefore the `-subfps` option should be used with this format. If you like to solve this problem permanently, you have to manually convert the subtitle file framerate. MPlayer can do this conversion for you:

    mplayer -dumpmicrodvdsub -fps subtitles_fps -subfps avi_fps -sub subtitle_filename dummy.avi

About DVD subtitles, read the DVD section.

### 2.7.1. MPlayer's own subtitle format (MPsub)

MPlayer introduces a new subtitle format called MPsub. It was designed by Gabucino. Basically its main feature is being dynamically time-based (although it has frame-based mode too). Example (from DOCS/tech/mpsub.sub):

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

    15 3
    A long long, time ago...

    0 3
    in a galaxy far away...

    0 3
    Naboo was under an attack.

So you see, the main goal was to make subtitle editing/timing/joining/cutting easy. And, if you - say - get an SSA subtitle but it's badly timed/delayed to your version of the movie, you simply do a

    mplayer dummy.avi -sub source.ssa -dumpmpsub

A `dump.mpsub` file will be created in the current directory, which will contain the source subtitle's text, but in MPsub format. Then you can freely add/subtract seconds to/from the subtitle.

Subtitles are displayed with a technique called 'OSD', On Screen Display. OSD is used to display current time, volume bar, seek bar etc.

### 2.7.2. Installing OSD and subtitles

You need an MPlayer font package to be able to use OSD/SUB feature. There are many ways to get it:

- Use the font generator tool at `TOOLS/subfont-c`. It's a complete tool to convert from TTF/Type1/etc font to mplayer font pkg (read `TOOLS/subfont-c/README` for details).

- Use the font generator GIMP plugin at `TOOLS/subfont-GIMP` (note: you must have HSI RAW plugin too, see http://realtime.ssu.ac.kr/~lethean/index.php?pagename=MplayerKoreanFonts).

- using a TrueType (TTF) font, by the means of the `freetype` library. Version 2.0.9 or greater is mandatory! Then you have two methods:

  - use the `-font `/path/to/sample_font.ttf`` option to specify a TrueType font file on every occasion

  - create a symlink:

        ln -s /path/to/sample_font.ttf ~/.mplayer/subfont.ttf

  If MPlayer was compiled with `fontconfig` support, the above methods won't work, instead the `-font` expects a `fontconfig` font name and defaults to the sans-serif font. To get a list of fonts known to `fontconfig`, use fc-list. Example: `-font `'Bitstream Vera Sans'``

- Download ready-to-use font packages from MPlayer site. Note: currently available fonts are limited for ISO 8859-1/2 support, but there are some other (including Korean, Russian, ISO 8859-8 etc) fonts at contrib/font section of FTP, made by users.

  Font should have appropriate `font.desc` file which maps unicode font positions to the actual code page of the subtitles text. Other solution is to have subtitles encoded in UTF-8 encoding and use `-utf8` option or just name the subtitles file `<video_name>.utf` and have it in the same dir as the video file. Recoding from different codepages to UTF-8 could be done by using konwert or iconv programs.

  Table 2.1. Some URLs

  URL | Comment
  --- | ---
  ftp://ftp.mplayerhq.hu/MPlayer/releases/fonts/ | ISO fonts
  ftp://ftp.mplayerhq.hu/MPlayer/contrib/fonts/ | various fonts by users
  http://realtime.ssu.ac.kr/~lethean/index.php?pagename=MplayerKoreanFonts | Korean fonts and RAW plugin

If you chose non-TTF fonts, UNZIP the file you downloaded to `~/.mplayer` or `$PREFIX/share/mplayer`. Then rename or symlink one of the extracted directories to `font`, for example:

    ln -s ~/.mplayer/arial-24 ~/.mplayer/font

Now you have to see a timer at the upper left corner of the movie (switch it off with the o key).

(subtitles are always enabled, for disabling them please read the man page)

OSD has 4 states (switch with o):

1. volume bar + seek bar (default)
2. volume bar + seek bar + timer + file position percentage on seeking
3. volume bar + seek bar + timer + total duration of the media
4. subtitles only

You can change default behaviour by setting `osdlevel` variable in config file, or the `-osdlevel` command line option.

### 2.7.3. OSD menu

MPlayer has a completely user definiable OSD Menu interface.

### Note

the Preferences menu is currently UNIMPLEMENTED!

Installation

1. compile MPlayer by passing the `--enable-menu` to `./configure`
2. make sure you have an OSD font installed
3. copy `etc/menu.conf` to your `.mplayer` directory
4. copy `etc/input.conf` to your `.mplayer` directory, or to the system-wide MPlayer config dir (default: `/usr/local/etc/mplayer`)
5. check and edit `input.conf` to enable menu movement keys (it is described there).

6. start MPlayer by the following example:

       $ mplayer -menu file.avi

7. push any menu key you defined

Prev | Up | Next
2.6. What about the GUI? | Home | 2.8. RTC