I get to deal with .srt files a lot at the moment. Not only does everything we produce needs to meet accessibility standards, but the default for social media video is that since it auto-plays without sound you need subtitles burnt-in so that people can watch it without clicking on it.
Due to frustration with the slowness and buggyness of Adobe’s subtitle tools I’ve built a streamlined subtitle burner-inner, which I will post soon, but at the moment it’s got a lot of only-works-on-my-machine-ism hard-coded into it.
For now, here’s a useful tool I built because I had the task of shifting all the subtitles in a file to cope with titles being added to the head, affecting all the timings. Rather than pay for a rush transcription job I built this.
One of the cool things about the script is that it uses powershell’s built-in date-time object to do all the time calculations. That makes it super easy – I’ve done this kind of thing with bash and JS a few times and it always involves lots of string parsing and mucking around with numbers to add and subtract timecodes.
Also it’s on GitHub. I finally made friends with git! So you can fork it at your leisure. Or if you just want to download it and run it, click here
Mulvya
You can also use ffmpeg to shift sub times.
ffmpeg -i in.srt -c copy -output_ts_offset 4.52 out.srt
All subtitle times will be delayed 4.52 seconds.
You can make them earlier, to bring forward 2.1 secs
ffmpeg -i in.srt -c copy -output_ts_offset -2.1 out.srt
However, when bringing them forward, ffmpeg will not produce negative timings. So if in the above case, the first line starts at 1.5 secs, then the offset will be -1.5 i.e. first line starts at 0, and all other timings are decreased by 1.5.
stib
Awesome, I’ve just reinvented the wheel. I should have checked to see if ffmpeg could do it.
Oh well, my time was not completely wasted, I learned how to make a git repository and about PS datetime functions, so there’s that.
CHRISTINA MCDONNELL
Hi, I’m just googling to find some help with powershell, as I don’t really know it and I dunno…it’s part of my job now. Anyway, I stumbled across your comment on superuser.com “That command seems to work just fine, but since it seems canonical to use cmd I’m wondering is it secretly killing puppies or something? “. You are funny so I guess I saw this website listed in your “signature” and followed the link to see if there was more “funny”. Thanks for making me laugh! Have a great day…or night.