BDSup2Sub, Perl, and ImageMagick--I'm a one-trick pony in that respect. BDSup2Sub to extract individual image files, Perl to script everything, and ImageMagick to handle the image compositing.
What I've got only really works with white subtitles with a black border. Yellow subtitles and such would require different code. Also if your subs aren't 720p, you may need to do some resizing. Can't guarantee it's bug-free, but even if there end up being problems, it still saves a lot of time.
Perl code below:
#!/usr/bin/perl -w
if($#ARGV==-1) {
print "Usage: perl assemble.pl <filename...>\n";
exit;
}
my @filelist=();
my @tmplist;
my $sourcefile;
for $sourcefile (@ARGV) {
if(-e $sourcefile) {
push(@filelist,$sourcefile);
} else {
@tmplist=glob($sourcefile);
my $listsize=@tmplist;
if($listsize==0) {
print "Error: Could not find $sourcefile\n";
exit;
}
push(@filelist,@tmplist);
}
}
my $pagenum="01";
my $currentpage="page".$pagenum.".png";
my $pagewidth=2480;
my $pageheight=3508;
my $tmpfile="tmp1.png";
my $leftmargin=$pagewidth/20;
my $topmargin=$pageheight/20;
my $bottommargin=$pageheight/18;
my $currentmargin=$topmargin;
unlink($currentpage);
FILELOOP: for $sourcefile (@filelist) {
if(!(-e $currentpage)) {
system("convert -size ".$pagewidth."x".$pageheight." xc:white $currentpage");
$currentmargin=$topmargin;
}
system("convert $sourcefile -negate $tmpfile");
my $imagewidth=0;
my $imageheight=0;
system("identify -format %wx%h $tmpfile > _dims.txt");
open(FILE2,"_dims.txt");
my $dims=<FILE2>;
close(FILE2);
unlink("_dims.txt");
my @bits=split(/x/,$dims);
$imagewidth=$bits[0];
$imageheight=$bits[1];
system("composite -compose atop -geometry +".$leftmargin."+".$currentmargin." $tmpfile $currentpage _".$currentpage);
unlink($tmpfile);
rename("_".$currentpage,$currentpage);
$currentmargin=$currentmargin+$imageheight+5;
if($currentmargin>=$pageheight-$bottommargin) {
$pagenum=$pagenum+1;
if(length($pagenum)<2) {
$pagenum="0".$pagenum;
}
$currentpage="page".$pagenum.".png";
}
}
print "Done.\n";
exit;