如何合并两个 *.srt 文件

Ste*_*fan 13 command-line video video-subtitles

请看这个问题。

我刚刚合并2个AVI文件cd1.avi,并cd1.avimovie.avi使用:

avimerge -o movie.avi -i cd{1,2}.avi
Run Code Online (Sandbox Code Playgroud)

问题是我必须为链接到第一个文件的文件添加字幕avi

cd1.srt
cd2.srt
Run Code Online (Sandbox Code Playgroud)

起初,我只是尝试将文件连接在一起:

cat cd{1,2}.srt > movie.srt
Run Code Online (Sandbox Code Playgroud)

但这对字幕造成了严重破坏......有什么建议吗?

Mic*_*zek 20

这是相当平凡的完成,因为.srt文件是包含时间戳只是文本文件-所有你需要做的就是添加的长度cd1.avi到所有的字幕的时间cd2.srt。您可以找到cd1.aviwith的长度ffmpeg

ffmpeg -i cd1.avi  # Look for the Duration: line
Run Code Online (Sandbox Code Playgroud)

然后将其添加到cd2.srt使用srttool

srttool -d 12345 -i cd2.srt  # 12345 is the amount to add in seconds
Run Code Online (Sandbox Code Playgroud)

或者:

srttool -a hh:mm:ss -i cd2.srt  # The first subtitle will now start at hh:mm:ss
Run Code Online (Sandbox Code Playgroud)

然后你应该能够将文件连接在一起并重新编号:

srttool -r -i cd.srt
Run Code Online (Sandbox Code Playgroud)

我选择srttool它是因为在 Arch 中它附带了transcode,你为这个问题安装了;还有许多其他工具也可以移动和合并.srt文件,至少有一个网站submerge