Skip to content

Add srt subtitles to mp4 files with ffmpeg

Published: January 30th, 2024 Video Image of buttons on a remote control. Lang, subtitle buttons can be seen.

Step 1

Go to the directory where your video files are.

Step 2

Make sure you have the desired subtitle files ( `.srt` ) and that they have the same filename as the source video files. So, if you have videofile_01.mp4, you should have videofile_01.srt.

Step 3

Make sure ffmpeg is installed.

Step 4

Copy the below script to a file, for instance: `add_subtitles.sh` and modify the file properties to make it executable.

chmod +x add_subtitles.sh

#!/bin/bash
for i in ./*.mp4
do
ffmpeg -i "$i" -i "${i%.*}.srt" -c copy -c:s mov_text "added/${i%.*}-added-subtitle.mp4";
echo -e "${1} converted successfully ${i%.*}-added-subtitle.mp4";
done
shell

Step 5

Execute the script by running add_subtitles.sh.

Step 6

Test the generated file(s) and remove the one(s) without subtitles if you want to free up some disk space.

Photo by Immo Wegmann

About Marcel Bootsman

Marcel discovered the web in 1995. Since then he has paid attention to and worked with lots of technologies and founded his own WordPress oriented business nostromo.nl in 2009.

Currently Marcel is Business Development Manager Dutch & DACH Markets at Kinsta where he helps Kinsta's client base grow with Managed WordPress, Application, Database and Static site hosting.

You can contact Marcel on a diverse range of online platforms. Please see the Connect section on the homepage for the details.