Skip to content

Instantly share code, notes, and snippets.

@solace
Last active July 17, 2022 00:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save solace/97e0b54ef35929bf05a3dcf1ae316ff5 to your computer and use it in GitHub Desktop.
Save solace/97e0b54ef35929bf05a3dcf1ae316ff5 to your computer and use it in GitHub Desktop.
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