This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Tools & Utilities

Subtitle manipulation tools for Linux

By Razvan T. Coloja on February 07, 2008 (7:00:00 PM)

Share    Print    Comments   

Subtitles may not mean much for the English-speaking part of the world, but for the rest of us, they are the difference between truly enjoying a movie or just watching the screen, trying to decipher the events. While Windows has a nice variety of tools to manipulate subtitles, Linux applications too can accomplish such tasks. From editing to ripping to converting, here is a list of some useful tools.

Gnome Subtitles is probably the best subtitle editing application in Linux. Not only does it offer an easy way to quickly translate subtitles in your own language, but it also provides a video player so that you can sync the text of the file with the words from the movie. Just pause, translate, and move on. You can mark the text as bold, italic, or underline with the click of a button. The application has a find and replace function that allows you to jump to known movie locations, and supports the different video framerates common to todays's movies: 23.976, 24, 25, 29.97, and 30.

On the left of the subtitle editing part of the window there is a column depicting the line number, and two other columns labeled From and To. A text line appears on the screen accordingly to the values of these two columns. You can choose between frames and times; times shows the position of the subtitle line in the movie by hour, minute, second, and millisecond and is easier to work with.

KSubtile is a KDE application that does the same thing as Gnome Subtitles, though it's not as intuitive and makes use of MPlayer to display the video. As soon as you load a subtitle, you'll see the number of lines in the file and the total length in minutes in the info tab. With KSubtile you can cut and copy subtitle lines from one part of the movie and paste them elsewhere. One downside of KSubtile is that it doesn't support UTF-8. One nice touch is a zoom feature that allows you to quickly find specified text. The subtitle text is represented as vertical lines in the Navigator part of the window. Wider lines mean frequent dialog. The editor offers two text boxes in the middle and two left and right arrows on the sides to help you navigate to the point you wish to change. Alternatively, you can press Select and jump directly to the place you want to edit the text.

While KSubtile makes use of MPlayer, the two components don't stay in sync, making the association pretty useless. As you scroll through the movie, the subtitles in the editing area remain the same, so you can't edit them based on the position in the video file sequence.

SubtitleEditor is a lightweight application, but it might help you translate faster than any of the other tools. In its main window you have the subtitle text, the start and end time sequence, the line number, and duration, among other columns. Just click on a line and you can already edit the text. It supports both ISO-8859-15 and UTF-8 and can play the associated movie file with MPlayer, VLC, or a video player of your choice. It even shows you the audio part of the movie so you'll know where to edit.

The application provides several view modes in the main window. Advanced view, for example, shows all the necessary columns, plus a style column and one that shows the number of character per line -- useful to approximate the text length as it appears on the screen with a certain font size. The Translation mode features the original text and an empty line at the right, ready to be filled. When you finish translating a file you can save it as SRT, SUB, TXT, ASS, or SSA.

Other subtitle editing apps you might want to try are Gaupol, GSubEdit and Jubler.

Subtitle tools in Linux are not limited to editing applications. If you want to convert a SUB file into SRT format, you can use the sub2srt Perl script. It converts MicroDVD and SUBRipper files to SubViewer format. You can even change the framerate with the -f switch.

Subtitles is an all-purpose subtitle Swiss Army knife. It can reload, retime, and convert subtitle files in a lot of ways. For example, say you have a subtitle file that displays the text three seconds late compared to the video file. All you have to do is type into a terminal subs -i -b 3 subtitle_file.sub and it's fixed.

Or suppose you downloaded subtitles for a movie encoded at 24fps, but the file itself is at 25fps. You can convert it with subs -i -a 24/25 subtitle_file.sub. You can even merge two subtitle files in such a way that the final file has the read time information from the first subtitle file and the text from the second one. Just use subs -z subtitle_file1.sub subtitle_file2.sub.

You know those comments that appear in some movie subtitles for the hearingly impaired? Things like [Laughter] or [Distant roar]. You can strip those out by using subs -e 's/[\s-]*\[.*\]\s*\n*//gs' subtitle_file.sub. Among other things that Subtitles can do are splitting a file after a determined period of time, separating overlapped lines, and joining files into a single subtitle.

How about ripping? That is, getting the image subtitles from a DVD into a SRT text file. You can rip the DVD with any DVD ripping tool, creating a /vob directory on your hard drive. Then install the transcode package and run tccat -i /home/user/rip/vob | tcextract -x ps1 -t vob -a 0x22 > subs-en. In this particular case, the 0x22 stands for English. To rip the subtitles for other languages, check out which ones are available with mplayer -dvd-device /space/st-tng/disc1/ -dvd 1 -vo null -ao null -frames 0 -v 2>&1 | grep sid and add the corresponding output number to the hexadecimal 0x20. If the Italian subtitle file has an SID of 7, you would do a tccat -i /home/user/rip/vob | tcextract -x ps1 -t vob -a 0x27 > subs-it to get them.

Since the DVD subtitles are embedded images, you can extract them with subtitle2pgm -o english -c 255,0,255,255 < subs-en. You need an external OCR application to detect the text in the image files. gocr does the job nicely: pgm2txt english. Finally, use srttool to create the SRT file: srttool -s -w < english.srtx > english.srt. Check the file afterwards to be sure all characters were detected correctly and all the words make sense. You might want to use OpenOffice.org to spell check the text.

If you'd rather rip subtitles the easy way, you can use KSubtitleRipper, a front end to the subtitleripper package. It uses the same extracting and converting tools as the CLI examples above, but unifies their use into a comprehensive GUI. If gocr can't recognize some characters, KSubtitleRipper asks you to replace them manually. It can work with both .vob and .sub files and provides internal spell checking.

So there you have it: you can now rip, convert, translate or manipulate subtitle files in whatever way you like, thanks to these simple yet effective utilities.

Razvan T. Coloja has published more than 150 Linux and IT-related articles in print and online magazines. He is an editor for a Romanian magazine and one of the maintainers and editors of www.mylro.org, a Romanian Linux/OSS portal and community.

Share    Print    Comments   

Comments

on Subtitle manipulation tools for Linux

Note: Comments are owned by the poster. We are not responsible for their content.

You ought to get out more

Posted by: Anonymous [ip: 82.192.250.149] on February 07, 2008 09:06 PM
'Subtitles may not mean much for the English-speaking part of the world,'.....

You mean you've never watched a non-American film, or an opera in Italian or German? Maybe you've never heard of Mozart?

#

Re: You ought to get out more

Posted by: Anonymous [ip: 24.86.18.41] on February 08, 2008 07:46 AM
Why would you need subtitles for Mozart?

#

UNIX

Posted by: Anonymous [ip: 88.147.65.196] on February 07, 2008 10:06 PM
Most of the subtitles files are text files. sed and awk are more than enough to manipulate them a lot of times. OK, not always, but somebody had to tell it.

#

Subtitle manipulation tools for Linux

Posted by: Anonymous [ip: 190.160.25.14] on February 07, 2008 10:41 PM
The work on subtitles rely more on sync, join and split subtitles than in raw text manipulation. So, you should use tools specific to the job.

#

Subtitle manipulation tools for Linux

Posted by: Anonymous [ip: 89.164.155.128] on February 08, 2008 07:32 AM
Hi!

If you need to produce subtitles for your project, ie. not just translate from one language to another then SubtitleEditor's feature to display the audio waveform is indispensable.

However, it was crashing here like mad and, despite I'm not fan of Java application, Jabbler is the only application which does the job.

So, imho, it was a mistake not to include in this review!!

Sincerely,
Gour

#

Subtitle manipulation tools for Linux

Posted by: Anonymous [ip: 212.74.14.96] on February 08, 2008 09:34 AM
"Subtitles may not mean much for the English-speaking part of the world"?????

Am I missing something here, or are there no English speaking deaf or hard of hearing people? Subtitles are a HUGE issue in the English speaking world! See Section 508 in the US, the DDA in UK just for starters. If you run a publicly available website and do not make it accessible, you lay yourself open to lawsuits, and accessibility includes video subtitling. It's an important issue that government sites in particular are having to take into account.

Thanks for the article, it's really useful :)

#

Subtitle manipulation tools for Linux

Posted by: Anonymous [ip: 10.12.24.143] on February 08, 2008 02:01 PM
I'd rather use Subtitle Workshop in Wine than any of those. I've never found any program as complete as SWS.

#

Subtitle manipulation tools for Linux

Posted by: Anonymous [ip: 222.153.225.11] on February 09, 2008 07:33 PM
I'm constantly amazed at the depth and capabilities of mplayer. mplayer is able to playback the slightly-nonstandard(?) mpeg files recorded by Elgato EyeTV on the Mac, but not the encoded VBI / Teletext data, which I think is encoded into the mpeg file as an auxiliary stream. My question is, does anyone know how to extract the teletext data stream out of the eyetv mpeg file?

#

Subtitle manipulation tools for Linux

Posted by: Anonymous [ip: 78.32.161.212] on February 10, 2008 10:26 PM
I often watch foreign films with my girlfriend . She needs Chinese subtitles and I need English. Using MPC on Windows with VSFilter I am able to have two different subtitle streams displayed at the same time. Its a bit of a hack but it works fine. Is there any way to playback a film with two subtitle streams displayed on Linux? This is one problem stopping me from migrating to Linux.

#

Subtitle manipulation tools for Linux

Posted by: Anonymous [ip: 92.80.29.138] on February 14, 2008 07:50 PM
Treadu frate tutorialu asta si in romana da-i in zlbz de vorbitori de engleza nu vezi ca te mai iau si la misto cu mozart cu alea alea. Sa asculte ei mozart cu subtitrari!!! :)))

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya