Splitting subtitles automatically

I’ve been doing a lot of subtitle work recently, and have really enjoyed using Annotation Edit, which does pretty much everything for subtitles. Except for one thing I ended up doing way too much- splitting subtitles into 2 lines.

So, I wrote a script that would take an STL, and split each line of text into 2 lines, as close to the middle as possible. To get started, download subtitleSplit.py and unzip.

To use subtitleSplit.py, open up Terminal on a Mac, and run the following command-

python /path/to/subtitleSplit.py -f /path/to/original.stl

This will split each line and spit it out into Terminal. To save this, you can either use the “>” trick, or specify an output file.

python /path/to/subtitleSplit.py -f /path/to/original.stl -o /path/to/new.stl

The default maximum characters per line is 35, but you may need to change that, depending on your text size and font. You can set that with the -m flag.

python /path/to/subtitleSplit.py -f /path/to/original.stl -o /path/to/new.stl -m 45

For coders, this file contains a class called SubtitleSplit, which contains more options than are available through the command line.

Let me know if you run into any problems.

Posted in Editing Tagged with: , ,

Leave a Reply

Your email address will not be published.



ChinStr.apps is a niche hobbyist app development company, specializing in apps for birders and homebrewers and in making Big Data relevant. Read more about ChinStr.apps.