Saturday, July 20, 2013

Modifying Subtitles with Python

Ok, so I have not been completely idle despite my debilitating sickness. I have actually been working on a problem regarding downloaded movies and their subtitles. I noticed that sometimes, movies that I have acquired have no subtitles. And the subtitles that I have downloaded from sites like opensubtitles.org are not synchronized with the movie itself.

So I spent an hour or so to write a simple Python app (now on Github) that will correct the problem. Just determine how far forward to push the subtitles so that it would be in synch with the movie.

For example, the following will push the subtitle movie by 2 minutes and 3 seconds:

python subtitle.py IronMan3.srt 00:02:03,000

I've tried it on a couple of subtitles. It all works great so far. Of course, it only pushes the subtitles forward -- not backward. It also does not do any error checking. It's also probably not very efficient.

Ah well, it does the job as I need it so far...