Subtitles not in sync with the playback? Let's fix that.

Updated: November 29, 2024

The problem you're facing is as follows. You would like to watch a movie in foreignese, and for that you need subtitles. Nowadays, it's quite trivial finding subtitle files for whichever movie you want, in a whole range of languages. You just need to grab an SRT (.srt) file, name it the same as your movie, and Bob's your uncle. Any self-respecting media player - or failing that, go for VLC, which is the best - will automatically load and display subtitles. But what if they are out of sync?

I talked about Linux and subtitles a long, long time ago. Most of what I wrote in that guide still holds. But I didn't cover the topic of time shift in the subtitle files. Perhaps you have the right words, but they are shown too late or too early. Even as little as 300ms difference can make the watching rather annoying. Anything above that is simply unplayable. Well, let me show you how you can quickly, and easily fix subtitles. After me.

Teaser

Name of the game: ffmpeg

In general, in life, if in doubt, and you're handling media files, ffmpeg. This can and should be your one-stop shop for all things video, audio, whatever. Most media editing programs are just elaborate frontends for ffmpeg. It's present in pretty much any and every tool that does some sort of moving pictures or sound out there. If you're using Linux, you're doubly in luck, because ffmpeg is available in pretty much all repositories.

I'm going to demonstrate the use of the program in Linux. The commands will be the same on all other operating systems, wherever you can run and install ffmpeg. The only difference is in how you obtain the program. Well, in Linux, it boils down to:

(sudo) [package manager] install ffmpeg

For example, in the Debian- and Ubuntu-based family of distros:

sudo apt install ffmpeg

Now, we need to fix the subtitle offset. I've already written a guide on ffmpeg, and it's reasonably comprehensive, and there's my  memes in HD article, too. Alas, much like the subtitle tutorial, it doesn't cover the time offset change. All right, the functionality is there, you just need a new flag. To wit:

ffmpeg -itsoffset [time] -i [subtitle file] -c copy [edited subtitle file]

A practical example:

ffmpeg -itsoffset -13.6 -i sub1.srt -c copy subs2.srt

What do we have here?

And that's it, Bob is truly your uncle!

Conclusion

Using Linux can be difficult sometimes. But then, there are also situations where it's pure blessing. In general, if you have various maintenance tasks, especially around media files, it offers a wealth of easily accessible tools and utilities to get the job done. No need to heedlessly wander around the net downloading random programs from weird websites, especially not in this modern age of everything-is-fake Internet.

Well, if you happen to be a consumer of worldwide media and not just plain ole English, sometimes, you may come across a film or three that you won't be able to understand natively, and some subtitles be necessary. You want those subtitles to fit the narrative. Should that not be the case, ffmpeg can easily solve the issue for you. The offset function is simple, fast, elegant. One or two seconds [sic], and you're done. That would be all for today, fellas.

Cheers.