More Subtitling

Sometimes I'm pretty thankful I'm so geeky.

Today I was helping someone from No More Deaths put subtitles on an interview with an undocumented migrant who was interviewed in the hospital here in Tucson after being picked up by border patrol. She was betrayed by coyotes and left for dead out in the desert, then rescued by suprisingly beneficient deer hunters.

I'm constanly surprised at how few real versatile, efficient tools for subtitling there are, especially for the Mac. There's just nothing that does everything you want. And so, often I'm stuck, massaging some text file into the right format, but luckily I speak the swiss-army knife of text processing languages, Perl. So when Shanti gave me a text file full of subtitles without time codes this afternoon, I just hacked together something like this:

#!/usr/bin/perl -n

$offset = 4; # time code to start.
$length = 9; # seconds each subtitle will last.

if(/^(\S.+)$/) {
$text = $1;
if($time == 0) { $start = $offset } else {$start = $time};
$time = $start + $length;
$start_seconds = $start % 60;
$start_minutes = int($start/60);
$end_seconds = $time % 60;
$end_minutes = int($time/60);
printf ("00:%02d:%02d:01,\t00:%02d:%02d:00,\t$text", $start_minutes, $start_seconds, $end_minutes, $end_seconds);
} else { print; }

Then import into DVD Studio Pro and voila! well, not quite voila, we still had to shift and stretch some things to get the timing a little better. But, y'know, if I didn't know Perl or some other way to roll my own text-munger, what would I do? spend an extra 5 hours on it I guess, getting the timing all figured out by hand. whew!

yay Perl!