Download source codes: Media:srt2csv.pl
After downloading, convert the file name from srt2csv.pl.txt to srt2csv.pl
#!/usr/bin/perl
while (<>) {
s/\r$//;
next if /^\d+$/;
if (/^(\d\d:\d\d:\d\d),(\d\d\d) --> (\d\d:\d\d:\d\d),(\d\d\d)/) {
$from=$1.$2;
$to=$3.$4;
} elsif (/^(.*\S)\s*$/) {
if ($text eq '') {
$text=$1;
} else {
$text .= "|" . $1;
}
} elsif (/^\s*$/) {
if ($from ne '' && $to ne '' && $text ne '') {
print $from, "\t", $to, "\t", $text, "\n";
}
$from='';
$to='';
$text ='';
}
Command Sample:
cat source.srt | perl srt2csv.pl > target.csv
Typical SRT sample:
5
00:00:13,612 --> 00:00:14,647 X1:269 X2:447 Y1:482 Y2:524
What's up?
Output sample
00:00:13612 00:00:13612 What's up?