Next Previous Contents

3. Scripts

A script is a file containing the text of the subtitles you want to display along with the exact times that each subtitle is to be displayed on the screen. Different subtitling programs use different file formats for their scripts. The subtitling program that we use, called mplayer, supports a total of ten different formats, which are listed here.

If you want to add your own subtitles to a movie, you can:

  1. Rip the subtitles off of the DVD (if it already has subtitles).
  2. Make your own script.
  3. Download a script from the internet and use it.
In the next three sections we cover these techniques in order.

3.1 Ripping subtitles off of the DVD

A lot of DVDs are starting to include subtitles on the disc itself. If your DVD comes with subtitles in the language you want, then you can rip those subtitles off of the disc and essentially get yourself a script for free. This procedure is useful even if the subtitles on the DVD are not in the same language as the language you want to subtitle in, since the timings on the disc will still be accurate even if the language is wrong.

The mplayer program comes with a subrip.c program in the TOOLS/ subdirectory, which is what we will use to rip the subtitles. You have to change a couple of lines in this program in order to get it to work:

  1. Change the #define GOCR_PROGRAM ... line to point to the actual installed location of the gocr program on your system.
  2. In the sprintf(cmd, GOCR_PROGRAM" ... line, get rid of all the -m options.

Then compile it according to the instructions at the top of the file.

Now you are all set to rip the subtitles off of your DVD:

rm frameno.avi
mencoder -dvd T -vobsubout subtitles -vobsuboutindex 0 -sid N -o frameno.avi -ovc frameno -nosound
subrip subtitles 0
where T is the title you want to rip, N is the subtitle number you want (see mplayer manpage), and is the output file for the subtitles.

Note that the gocr program is not very good, so you will definitely have to hit with a text editor and correct all of the character recognition mistakes that gocr makes. If the subtitles are not in a language that at least uses the Roman alphabet, then the gocr output is completely useless, but the times listed in the file should still be accurate.

The file is in SubRip (SRT) format, which is compatible with mplayer. Just use the filename wherever this guide refers to script.mpsub from now on.

3.2 Making your own script

In order to make your own script, you need to record all the lines of dialogue in the movie, translate them, and then record the start time and end time of each line so that you know when to have the subtitle appear and disappear. While the translation process is straightforward (assuming you know the language...), the task of timing the dialogue is almost impossible without specialized software to help you out. Here you have two options. You can use Windows software, which is what everybody else does, or you can be brave and try to do it in Linux as I describe below.

Timing in Windows

To time the dialogue in windows, rip the audio from the DVD into .wav format as described in Ripping the audio for timing purposes, and then use the freeware Windows program Sub Station Alpha to time the dialogue from the .wav file as described in the Sub Station Alpha documentation. The Karinkuru Guide To Subtitling also has many useful tips on how to use Sub Station Alpha for timing.

If you use Sub Station Alpha for timing then you will end up with a script in Sub Station Alpha format. The example section describes how to convert the resulting script file into something usable by mplayer.

Timing in Linux

I have a separate page explaining the setup that I use for WAV timing in Linux. This procedure does work, and it is very easy for me to use, but most people will probably find it too hard to get running.

Another alternative is to use xste, which claims to perform WAV timing, but I have never gotten this software working.

3.3 Downloading timed scripts

Another way to get a script is to download one. For most popular anime titles, you can find a script for it from one of the following web sites:

The most popular formats used for timed scripts within the anime fansubbing community are Sub Station Alpha and JACOsub scripts. There are also others; see for a larger list.

The mplayer program can read most popular subtitle file formats. See here for a list of what file formats it can read. (Note that the popular DVDSubber format is just a zip file containing a Sub Station Alpha script, so mplayer can handle those just fine once you unzip them.) If you download a script which is in an unsupported format, you will have to find some way to convert the file into a format which mplayer can read.

Example of preparing scripts for use in mplayer

The following example assumes that you are starting out with a Sub Station Alpha script and you want to use it to display subtitles with mplayer. Most of the following applies to other script formats as well, but there will be minor details which differ.

Please take note of the following limitations in the mplayer subtitling engine, since they will make your life more difficult than that of a traditional subtitlier:

The best way to cope with these limitations is to first remove all instances of simultaneous subtitles from your .ssa script, and then convert your .ssa file into .mpsub format and edit the .mpsub file to remove any leftover .ssa formatting codes. You can do the first by running Sub Station Alpha and removing all "collisions" (search the help file for this term). To do the second, simply stick the DVD that you're subtitling into your DVD-ROM drive, and type

mplayer -sub script.ssa -dumpmpsub -dvd 1

where script.ssa is the filename of your script. The above command will generate a file called dump.mpsub which is a converted version of your original script. Copy this file somewhere else (for example, script.mpsub), and use any text editor to remove all Sub Station Alpha formatting commands (meaning anything inside braces) from the script.mpsub script.

At this point you should be able to play back the DVD together with the script.mpsub script and enjoy a beautifully subtitled version of your DVD:

mplayer -sub script.mpsub -npp ci -dvd 1

(You may need to replace -dvd 1 with -dvd N where N is the DVD title that you are interested in.) If this step does not work, then fix it before going on; the subtitling process uses the same code as the playback process and it will not work unless you already have playback working.

Next Previous Contents