Fixing Problems With Subtitles Files
I wrote a python script which fixes two common problems with subtitles files.
The first problem the script solves is the offset you find sometimes between the the time the subtitles are supposed to appear on the screen and the time they actually appear. The script very swiftly synchronizes the subtitles and the video when you provide it with the number of minutes and/or seconds that make up the offset.
Note that this fix applies only to cases where the file's time offset is constant throughout the video (e.g. the difference is always 3 seconds); in cases where the offset changes frequently this script won't help you. You can look for other software to help you fix this particular issue, but having done some research myself I recommend you save yourself a headache and just download a different subtitles file.
The second problem the script solves is the presence of closed captions. Closed captions are very beneficial for the hearing impaired, but for the rest of us they can be very annoying. This script removes them with extreme prejudice.
This script works only on files of the type ".srt", the most common type of subtitles files.
Options:
--ma : Add minutes (integers only)
--ms : Subtract minutes (integers only)
--sa : Add seconds (integers only)
--ss : Subtract seconds (integers only)
--nocc : Remove closed captions
_For example, to subtract 3 seconds from the timestamps:
python subtitlefix.py --ss 3 [PATH/]filename.srt
_To remove closed captions:
python subtitlefix.py --nocc [PATH/]filename.srt
_You can do more than one operation on the file at the same time. For example, to add 1 minute and 20 seconds and get rid of closed captions at the same time:
python subtitlefix.py --ma 1 --sa 20 --nocc [PATH/]filename.srt
Note that the order of the options isn't important.
As usual, since neocities doesn't allow the upload of python files, the code is uploaded inside a text file:
subtitlefix.txt
Enjoy your movie night!
Posted: 26-04-2022
Tags: software