Skip to content

Instantly share code, notes, and snippets.

Last active February 14, 2023 20:59
What would you like to do?
Add English subtitles to videos with Turkish language audio


Install the following dependencies

brew install pipenv
brew install ffmpeg
pipenv install --python 3.10


Activate a pipenv shell and make sure the following python packages are installed

pipenv shell --python 3.10
pip3 install ffmpeg-python
pip3 install git+ 

Setup input/output directories

mkdir -p input
mkdir -p output

Move files you want to process to a directory called "input"

Run the script


Run Time Expectations

I ran this on a 15 minute video file and it took about 2 hours to process.

Special Thanks

To Alex for figuring all this out in the first place and writing the script

set -xe
filenamefunc () {
for file in input/*; do
echo "$(date) ---------- starting whisper ----------"
whisper --model $model_size "$file" --language $language --task translate --fp16 False
echo "$(date) ---------- starting ffmpeg ----------"
ffmpeg -i "$file" -vf subtitles="$(basename "$file")".srt output/"$(basename "$file" .mp4)"_engsub.mp4
cleanup () {
for file in input/*; do
rm -rf "$(basename "$file")".srt
rm -rf "$(basename "$file")".vtt
rm -rf "$(basename "$file")".txt
rm -rf "$(basename "$file")".json
rm -rf "$(basename "$file")".tsv
echo "$(date) ---------- starting filenamefunc ----------"
echo "$(date) ---------- starting cleanup ----------"
echo "$(date) ---------- finished ----------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment