Sublime Forum

Adjust timing/seconds in entire file?

#1

I’m working with a set of subtitle files in which all text is a few seconds behind on the videos they’re supposed to run under. I’ve been solving this by adjusting all the timing manually, but as this takes up a lot of time, I’m wondering if there is a way to automatically change all timing, let’s say, 4 seconds back?

0 Likes

#2

ofc it’s possible, but I’m not sure how we’re supposed to help you without an example… :wink:

1 Like

#3

Ok, so for example in one file I have this:

1
00:00:00,000 --> 00:00:03,937
[MUSIC]

2
00:00:03,937 --> 00:00:08,588
I think you have already encountered…

etc.

… while actually, in the video, there is no music and the text starts at 00:00:00,000. That makes that the text is constantly four seconds behind on the video. So in this case, I’d need all the timing to be - 03,937 seconds for the text to align with the video.

Does that clarify it?

0 Likes

#4

You could do this via a single-purpose TextCommand. You’d want to use view.find to locate these timestamps, then get the contents with view.substr, parse them, do your math, serialize them, and then use view.replace to modify the file.

0 Likes

#5

Here’s also a quick way:

  1. Install Insert Nums
  2. Search for \d+,\d+ in the file (regular expression) and “select all”
  3. Select “Insert Nums” in the command palette
  4. Enter |"{0:06.3f}".format(float(_.replace(',','.')) - 3.937).replace('.',',') into the panel and hit enter

PS: If it weren’t for the comma used as the decimal separator, this could’ve looked like this: f|~06.3f::_- 3.937.

4 Likes

#6

Thank you for the help!

0 Likes