Pages

Wednesday, 13 March 2013

A script to synchronize subtitles

When we are seeing a subtitled video, sometimes can be happen that video and subtitles are not perfectly synchronized. The solution can be, either use one of the online service to re-synchronize the subtitles or just download another subtitles file and hope to be lucky that will be the right one.
Well, I have written a simple python script for linux, to synchronize manually the *.str file.


You can download the script, or also write these command in the terminal:
mkdir ~/.bin
echo 'export PATH=${PATH}:~/.bin' >> ~/.bashrc
cd ~/.bin
wget https://sites.google.com/site/epclinuxfile/config/pagetemplates/files/sync_sub
chmod +x sync_sub

We have created a directory /.bin in the home, downloaded the file there and make it executable. Then we can just execute the script writing in the terminal:
sync_sub -i input.str -o output.str -d +3,000
where:
  • input.str is the subtitle file that we want to modify,
  • output.str is the output modified file,
  • +3,000 is the time shifting, a delay of 3 second, we can also put a negative delay, with the precision of millisecond.

This is just an home made script, you can modify it if you want, but ask to me if you want redistribute it. 
For any question or advice, leave a comment.

No comments:

Post a Comment