[FFmpeg-user] Add subtitles and chapter metadata in one pass?

George Welch george at grwelch.com
Mon Oct 12 22:29:53 EEST 2020


Howdy,

I need to start with a movie file that has audio and video, and to 
reencode the video and add subtitles and chapter markers.

I can add the chapters in a first pass, and then add the subtitles in a 
second pass, and that works fine.  But I can't seem to find the right 
command to add subtitles and chapters in one pass.

For example, here is a sequence that does work:

$ ffmpeg -i avfile.mkv -i metadata.txt \
     -map 0:v -map 0:a -map_metadata 1 \
         -c:v libx264 [ various options ] \
         -c:a copy \
             temp.mkv
$ ffmpeg -i temp.mkv -i srtfile.srt \
     -map 0:v -map 0:a -map 1:s \
         -c:v copy \
         -c:a copy \
         -c:s srt \
             out.mkv

However, I would like to skip the intermediate file.  Here is the 
command I am trying which does *not* work:

$ ffmpeg -i avfile.mkv -i srtfile.srt -i metadata.txt \
     -map 0:v -map 0:a -map 1:s -map_metadata 2 \
         -c:v libx264 [ various options ] \
         -c:a copy \
         -c:s srt \
             out.mkv

Can anyone tell me a command that will work, and hopefully explain what 
I have wrong?

Thanks!

--George


More information about the ffmpeg-user mailing list