This is how I did it:
I first checked the end timestamp of the first srt file. In my case, the first timestamp of the second one started immediately after, so the shifting timespan was easy to deduce.
Having this, and as mentioned by @aviro in the comments of your answer, I used pysrt with the timespan I deduced above.
pip install pysrt
srt -i shift 1h2m58s cd2.srt
Then before merging the two srt
files, we need to offset the sub counter at cd2.srt for them to work properly.
For this I used this python script to generated the fully offsetted cd2.srt
:
(replace $numX with (sum of subtitles in cd1.srt)+1)
# Open the input file for reading
with open('cd2.srt', 'r') as input_file:
# Open the output file for writing
with open('cd2.output.srt', 'w') as output_file:
# Iterate over each line in the input file
for line in input_file:
# Check if the line contains a single integer
if line.strip().isdigit():
# Convert the line to an integer
number = int(line)
# Add $numX to the number
number += $numX
# Write the resulting number to the output file
output_file.write(str(number) + '\n')
else:
# Write the original line to the output file
output_file.write(line)
then perform the final merge via: cat cd1.srt cd2.output.srt > final.srt
Now the subtitles should work fine alongside your newly merged video file!