Skip to content

Instantly share code, notes, and snippets.

@solace
Last active Oct 21, 2021
Embed
What would you like to do?
Bake-in captions into videos using srts and ffmpeg
#!/bin/bash
# Check out STEAM Powered (https://steampoweredshow.com/) where I have conversations
# with women in STEAM to learn a bit about what they do and who they are.
# https://steampoweredshow.com/learn-more/
# Usage
# =====
#
# Execute script in the directory containing the video and srts files, or modify to take
# a path argument.
#
# Expects the directory to contain the video files with correspondingly named
# srt files in the same directory.
# ie. If there is a file named video.mov, there should be a video.en_US.srt to apply.
# Outputs a new videosubs.mp4 file.
#
# For individual video files, use the ffmpeg command on its own.
# Change input video file extension as needed.
find -E . -type f -regex ".*.mov" -print0 | while IFS= read -r -d '' name;
do
f=$(basename -- "$name")
# Modify the SRT suffix to match your required language, or remove.
# Change output video file suffix and extension as needed.
ffmpeg -nostdin -i "$f" -vf subtitles="$f.en_US.srt" "${f%w.*}subs.mp4" < /dev/null
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment