Subtitle offset modificator
What is it ?
One day, I downloaded a subtitle file for a DivX?
movie I already had. Unfortunately, the subtitles didn't had the correct timestamps : they started a few seconds after the voice. Mplayer has an option called -subdelay
that allows to delay the subtitles. But this did not modified the subtitle file, so you had to remember the offset value for each movie you have ... not easy.
So, I wrote a simple Perl script that changes the timestamps of a subtitle file, either with a positive or a negative offset. It works on SRT
substitle files, whose entries look like this :
00:01:22,637 --> 00:01:25,640
Everything's bigger in America,
Using the script is really simple :
./subtitle-offset-modificator.pl infile.srt outfile.srt offset
Where offset is of the form hh:mm:ss,fff
are the hours, mm
the minutes, ss
the seconds and fff
the frames). The offset can start with a plus or minus sign (if no sign is given, plus is the default).
Add 8 seconds to all timestamps
./subtitle-offset-modificator.pl infile.srt outfile.srt 00:00:08,000
Substract 4 seconds to all timestamps
./subtitle-offset-modificator.pl infile.srt outfile.srt -00:00:04,000
Here is the subtitle-offset-modificator Perl script
Of course, it's released under the GNU General Public License
I am not a Perl guru, I only use this language occasionnally, so the code might be very suboptimal and dirty. If you have any remark regarding the code, don't hesitate to tell me, I am always happy to learn new things, especially when it concerns getting things cleaner !
Feel free to report any bugs or give your suggestions.