How to batch add subtitles to videos using ffmpeg

 

for n in $(seq -w 01 26); do ffmpeg -i inputvideo${n}.mkv -i inputsubtitle${n}.srt -c copy outputvideo${n}_sub.mkv; done

So in this example we have all video files and subtitle files in one folder. The video files are named all in the pattern “inputvideo${n}.mkv” and the subtitles in “inputsubtitle${n}.srt” In total we have 26 videos and 26 subtitles that we want to map to them. Thats why we count from 01 to 26 in the beginning “$(seq -w 01 26)”.  The output files are only videos. because we want to embedd the subtitle file into the video file. Our output videos are called  “outputvideo${n}_sub.mkv” in that way we make sure that we easily can see (_sub at the end of the file name) what file has a subtitle attached to it and which one not.

the -c copy option means we want to copy it all into a new file. the -i mark the inputs for ffmpeg.

I hope this is helpful for you to batch add subtitles to video files.