I have a bunch of subtitle files (all .srt) which don't really match the videos they belong to. The problem is two-fold:

  1. The video's intro has been cut off, but the subtitles still expect it to be there.
  2. There are certain "intermezzos" (or transitions) which also appear to be shortened relative to the subtitles. For example, That 70s Show has a few transitions per episode where some cast members are basically messing around in front of the camera for a couple seconds. Now imagine that every transition is shortened by 1 or 2 seconds as opposed to what the subs expect.

Now, for point 1 I can simply timeshift the entire subtitle file so the first line for both is in sync. However, I can't simply shift the entire file again for those transitions in point 2, because that would mess it up again. So I'm looking for a tool that supports e.g. -t 10:00:00 -s +2.0 and it will only shift the subs by 2 seconds from the 10 minute mark on, leaving everything before it alone. Ideally, it also supports in-place replacement/updating of the existing file, but it's no big deal if it doesn't.

It doesn't seem to be a problem with slightly different framerates (e.g. 23.98 vs. 24), because when I figure out by how much to shift the subs (usually whole seconds), it consistently matches the video until the next transition. It's not slowly becoming desynced as the episode goes on.

The tool must be without a GUI because the subtitle/video files live on a Linux box without a desktop environment and installing one just for shifting subs is way overkill. I also want to keep all that stuff together on the same device. It doesn't have to be a compiled executable, a Python script or whatever would be fine too.

  • can the mpv command and its --sub-delay option do this? together with some other command-line-option and some shell scripting? (mpv is a video player)
    – knb
    Commented Sep 17, 2020 at 9:08
  • @knb Unfortunately not, it still seems to expect a video file and I'll wager it will only keep the changes in-memory while playing that particular video.
    – Sahbi
    Commented Sep 17, 2020 at 14:03

1 Answer 1


I finally decided to take the time and write something that fulfills all conditions myself. It uses some odd language though, simply because I like it that way (I don't think it contains anything potentially offensive).

  • GUI-less: it's a good ol' Perl script.
  • Can shift entire subtitles, or pick up from a certain point (in HH:MM:SS,ms format).
  • Accepts both positive and negative time shift values. If the resulting timestamp would be "below" 00:00:00,000 it does not wrap around to e.g. 24:00:00,000, it simply produces negative timestamps. For me this is a big plus, since it basically means hiding the subs that would appear on-screen while keeping the content. This can happen if the subtitles expect a sort of teaser at the start of an episode, but the actual video doesn't contain this.
  • Supports in-place replacement. It actually first writes to a separate file before renaming it to overwrite the original, but the result is the same.
  • Perhaps not unimportant: it can work on multiple files at the same time, so you could easily/quickly fix subs for an entire season.
  • Only .srt is (currently) supported.
  • 2
    If it's public, I don't see any reason why it cannot be named here, both for promoting and for helping future members searching for similar things. Put a warning for all things you think others may not like if you're concerned.
    – Alejandro
    Commented Nov 24, 2020 at 19:55
  • Even if you accepted it: it's not an answer as its not available anywhere (but to yourself). So as Alejandro wrote: Please edit your post, include the details – and yes, please link to it! You gave full disclosure it's your own work, so it wouldn't seen as "spammy advert". Else we'd have to convert this to a comment, for the reasons I just gave. Thanks in advance!
    – Izzy
    Commented Nov 24, 2020 at 20:56
  • Sure, if it's not a problem I'll edit the answer to include a link. @Izzy You also mentioned including details, but everything's explained in the readme and knowing e.g. any supported arguments isn't very useful if you don't have the script itself. The requirements were also already stated in the OP. Could you elaborate exactly what sort of details you meant?
    – Sahbi
    Commented Nov 24, 2020 at 21:25
  • Well, I cannot tell what's in the readme without having seen it. Neither do other readers. Just imagine you were still searching, didn't know of your program, and now would find this post. What would you expect to see before follow a link off-site (to know it's worth being followed)? I guess basically some facts on how it meets the requirements of the question. This could eg be a short bullet-point list. No need to write an essay ;) More hints in our discussion on what makes an answer high quality (recommended reading ;)
    – Izzy
    Commented Nov 24, 2020 at 21:36
  • I think I'm generally a pretty good judge of what constitutes a high quality answer, this is just an odd/unclear case (at least for me). I've updated the answer, how's that? =]
    – Sahbi
    Commented Nov 24, 2020 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.