.srt subtitle shifter
") != -1)
{
startHours = parseInt(myArray[k].substr(0, 2), 10);
startMinutes = parseInt(myArray[k].substr(3, 2), 10);
startSeconds = parseInt(myArray[k].substr(6, 2), 10);
startMilliseconds = parseInt(myArray[k].substr(9, 3), 10);
startTotal = startHours*60*60*1000 + startMinutes*60*1000 + startSeconds*1000 + startMilliseconds + delta;
finishHours = parseInt(myArray[k].substr(17, 2), 10);
finishSeconds = parseInt(myArray[k].substr(23, 2), 10);
finishMinutes = parseInt(myArray[k].substr(20, 2), 10);
finishMilliseconds = parseInt(myArray[k].substr(26, 3), 10);
finishTotal = finishHours*60*60*1000 + finishMinutes*60*1000 + finishSeconds*1000 + finishMilliseconds + delta;
//added by mittu
if(startTotal < 0 )
{
startTotal += HUGE_TIME;
} else if(startTotal >= HUGE_TIME)
{
startTotal -= HUGE_TIME;
}
//added by mittu
if(finishTotal < 0 )
{
finishTotal += HUGE_TIME;
} else if(finishTotal >= HUGE_TIME)
{
finishTotal -= HUGE_TIME;
}
startMilliseconds = startTotal%1000;
startTotal = Math.floor(startTotal/1000);
startSeconds = startTotal%60;
startTotal = Math.floor(startTotal/60);
startMinutes = startTotal%60;
startHours = Math.floor(startTotal/60);
finishMilliseconds = finishTotal%1000;
finishTotal = Math.floor(finishTotal/1000);
finishSeconds = finishTotal%60;
finishTotal = Math.floor(finishTotal/60);
finishMinutes = finishTotal%60;
finishHours = Math.floor(finishTotal/60);
newString = pad(startHours, 2) + ":" + pad(startMinutes, 2) + ":" + pad(startSeconds, 2) + "," + pad(startMilliseconds, 3) + " --> " +
pad(finishHours, 2) + ":" + pad(finishMinutes, 2) + ":" + pad(finishSeconds, 2) + "," + pad(finishMilliseconds, 3);
myArray[k] = newString;
}
}
newString = myArray[0];
for (var k = 1; k < myArray.length; k++)
newString += "\n" + myArray[k];
document.getElementById("srt").value = newString;
setStatus("Done. Ready.");
}
-->
.srt Subtitle Shifter
This script takes a .srt text (just open an .srt file with a text editor,
select all and copy-paste the contents of it in here) and shifts the time
backwards or forwards around by a given number of seconds. Useful for when you
download a movie which has been cut a bit, for example the initial credits were
cut or a logo was added in to the beginning and the subtitles are now out of
sync with the movie. Be aware, it may take a while if the text is particularly,
long depending on your PC. Just sit back and wait. After it's done, paste it
back into your subtitle file.