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/bashfor i in ./*.mp4doffmpeg -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";doneshell
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