RSS Feed
Nov 16

HowTo: Create your own subtitles to display on video in Totem

Posted on Sunday, November 16, 2008 in Tutorials

Subtitles – a simple, but effective means of communication for speakers of non native languages and the hard-of-hearing. We see subtitles in DVD’s and on TV in various forms.

It would be good to utilise subtitles for a home video that you have encoded to give to your parents or grandparents, both of whom are a little hard-of-hearing, but it’s an effort to add subtitles to a video, encode it again and it will ultimately bother those people who don’t need to view the subtitles.

You don’t have to encode the subtitles as part of the physical video, however. Most media players, including Ubuntu’s Totem have the ability to overlay subtitles on top of the video being played back. This allows you to create your own custom subtitles and be able to modify them as required without any need to re-encode the video.

So how do you create subtitles? Well, first up you need a transcript of the video you are subtitling. In this example, I’m going to use an old news story I have recorded from TV. The file is called GasLeak.mpg and is located in my ~/videos directory. To subtitle it, you need to create a text file with the same name as the video in the same directory, thus:

gedit ~/videos/GasLeak.srt

(note the .srt extension replaces the .mpg extension. This marks it as a subtitle file)

Your text editor will now appear with a clean slate. Move this window aside, but don’t close it.

Now fire up your video in Totem and let it play. As people speak, type what they say into GEdit. Use one line per sentence, thus in my case:

Help at last for victims of the HIH collapse.
A gas leak brings a section of the city to a standstill.
And angry protests as our new Catholic Archbishop takes the reigns.

…etc. Do this for the entire video. You may have to pause and rewind the video several times to keep up with transcribing.

Once you have the raw text down, now it’s time to format it so that Totem recognises it and knows when to display each line.

Each subtitle has to have a sequential number to identify it, plus a start and end time to display as follows:

1
00:00:10,000 --> 00:00:14,000
Help at last for victims of the HIH collapse.

2
00:00:14,000 --> 00:00:18,000
A gas leak brings a section of the city to a standstill.

3
00:00:18,000 --> 00:00:23,000
And angry protests as our new Catholic Archbishop takes the reigns.

So above we have three subtitles numbered 1 through 3. After each number, we have the time period that each subtitle will appear for. The left-most numbers are the start-time for the subtitle in the form of HH:MM:SS,FFF (where HH is hours, MM is minutes, SS is seconds and FFF is hundredths of one second between 000 and 999), and the right-most numbers is the finish time for the subtitle in the same format.

The time given is the time of the video stream itself, so if you have an hour-long video, your subtitles will sequentially count in from from 00:00:00,000 all the way through to 01:00:00,000. In the above example, the first subtitle will appear 10 seconds into the video and will disappear at the 14 second mark (thus making the subtitle appear for a total of four seconds).

The second subtitle appears immediately after the first at 14 seconds and disappears at 18 seconds, and the third subtitle appears at 18 seconds and disappears at 23 seconds.

Save the file and fire up your video in Totem to see how what you’ve done so far looks.

Our simple subtitle in all its glory

Our simple subtitle in all its glory

If you cannot see the subtitles, it is possible that the feature is not enabled – go to Edit->Preferences and make sure the “Automatically load subtitle files when movie is loaded” at the middle-bottom of the window is checked in the General tab, then close Totem and re-open your movie.

Totem Preferences showing Subtitle display options

Totem Preferences showing Subtitle display options

Great! We now have working subtitles, but the timing is out. This is where you have to fine-tune the timings to the video and will require you to watch the video again, keeping an eye on the timer as you go. Just jot down the approximate whole seconds for when each subtitle should appear and go back and update the subtitle file accordingly.

Save and re-open your video. To further fine-tune the appearance of the subtitles, you can now edit the hundredths-of-a-second value to allow subtitles to appear at half a second instead of the whole second, etc. In my case, my tuned subtitle file now looks like:

1
00:00:10,500 --> 00:00:14,000
Help at last for victims of the HIH collapse.

2
00:00:14,500 --> 00:00:18,000
A gas leak brings a section of the city to a standstill.

3
00:00:18,400 --> 00:00:23,000
And angry protests as our new Catholic Archbishop takes the reigns.

I tweaked the first subtitle to appear at 10.5 seconds, terminating at 14 seconds. The second title appears at 14.5 seconds and finishes at 18 seconds, and the third subtitle appears at almost 18.5 seconds and finishes at 23 seconds.

It may take some time, but once done, you will have a perfectly subtitled home video.

But wait, there’s more! You can enhance the subtitles a bit with italic and underline tags!

By enclosing your subtitle text in <i> and </i> for italics and <u> and </u> for underline, you can format the text a bit to highlight aspects of it, for example italics are generally used to subtitle a voice off-camera such as a narrator. As an example:

1
00:00:10,500 --> 00:00:14,000
<i>Help <u>at last</u> for victims of the HIH collapse.</i>

Which will italicise the entire subtitle, and underline just the words “at last”.

Formatted subtitle with italic and underline

Formatted subtitle with italic and underline

Now this is all well and good, but the subtitles still look kinda small. Can we make them bigger? Well, the actual font size is determined by Totem’s font size setting under Edit->Preferences->General (by default it’s 20 points), but generally the resolution of the source video will ultimately govern how that font physically appears. Here’s an example of the same video clip in low, medium and high resolutions using the same subtitle file:

Subtitles on a 192x144 size video

Subtitles on a 192x144 size video

Subtitles on a 384x288 size video

Subtitles on a 384x288 size video

Subtitles on a 720x576 size video

Subtitles on a 720x576 size video

As you’ve already noticed, Totem will word-wrap long subtitles, but sometimes this can result in orphaned words. You can make your subtitles even more readable by breaking them up into multiple lines, eg:

1
00:00:10,500 --> 00:00:14,000
<i>Help <u>at last</u> for
 victims of the HIH collapse.</i>

Will make the subtitle appear as follows:

Subtitle broken into multiple lines

Subtitle broken into multiple lines

…which looks much nicer.

That’s basically it! Now when you email/post the video to your folks, make sure the .srt file accompanies it in the same directory and Totem will automagically open it and utilise the subtitles. Should you want to turn the subtitles off without deleting the .srt file, simply go to View->Subtitles->None while the video is playing in Totem.


Be a hero - add the first comment!

Leave a Reply

Spam Protection by WP-SpamFree