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?
Adjust timing/seconds in entire file?
ofc it’s possible, but I’m not sure how we’re supposed to help you without an example…
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?
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.
Here’s also a quick way:
- Install Insert Nums
- Search for
\d+,\d+
in the file (regular expression) and “select all” - Select “Insert Nums” in the command palette
- 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
.