How do I merge two *.srt files

9,870

This is pretty trivially done, since .srt files are just text files that contain time stamps -- all you need to do is add the length of cd1.avi to the times of all the subtitles in cd2.srt. You can find the length of cd1.avi with ffmpeg:

ffmpeg -i cd1.avi  # Look for the Duration: line

And then add that to cd2.srt using srttool

srttool -d 12345 -i cd2.srt  # 12345 is the amount to add in seconds

or:

srttool -a hh:mm:ss -i cd2.srt  # The first subtitle will now start at hh:mm:ss

Then you should just be able to concatenate the files together and renumber:

srttool -r -i cd.srt

I picked srttool because in Arch it comes with transcode, which you installed for this question; there are lots of other tools that can shift and merge .srt files too, and at least one website, submerge

Share:
9,870

Related videos on Youtube

Stefan
Author by

Stefan

I like code, beer, rock climbing and travel.

Updated on September 17, 2022

Comments

  • Stefan
    Stefan almost 2 years

    Please see this question.

    I have just merged two avi files cd1.avi and cd1.avi into movie.avi using:

    avimerge -o movie.avi -i cd{1,2}.avi
    

    Problem is that I had to subtitle files linked to the first avi files:

    cd1.srt
    cd2.srt
    

    At first I tried simply to concatenate the files together:

    cat cd{1,2}.srt > movie.srt
    

    But that caused havoc with the subtitles... any suggestions?

  • Stefan
    Stefan almost 14 years
    +1 thanks micheal, really appreciate your efforts with my questions
  • Jeremy
    Jeremy over 12 years
    Thanks! This worked great. Only problem I found is that srttool puts output to the command line. I actually doesn't modify the file you want. A little redirection (>) and WHAMMO, it works perfectly. This has been a huge help and thank you very much.
  • Konrad Szałwiński
    Konrad Szałwiński almost 4 years
    How do you install srttool on MacOS?