Skip to content

Instantly share code, notes, and snippets.

@res0nat0r
Created October 17, 2009 03:56
Show Gist options
  • Save res0nat0r/212225 to your computer and use it in GitHub Desktop.
Save res0nat0r/212225 to your computer and use it in GitHub Desktop.
Convert ASS subs to SRT
#!/usr/bin/perl
use strict qw(subs vars);
my $counter;
while(<>) {
if(/^Dialogue: /) {
my ($start, $end, $text) = unpack("x12A10xA10x22A*", $_);
my ($hr, $min, $sec) = split(/:/, $start);
$hr = sprintf("%02d", $hr);
$min = sprintf("%02d", $min);
$sec =~ s/\./,/; $sec = $sec . "0";
$counter++;
print "$counter\n";
print "$hr:$min:$sec --> ";
($hr, $min, $sec) = split(/:/, $end);
$hr = sprintf("%02d", $hr);
$min = sprintf("%02d", $min);
$sec =~ s/\./,/; $sec = $sec . "0";
print "$hr:$min:$sec\n";
$text =~ s/\\N/\n/g;
print "$text\n\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment