Skip to content

Instantly share code, notes, and snippets.

@ryanfb
Created March 28, 2024 18:13
Show Gist options
  • Save ryanfb/b974f502939c27b3967607423e50e23f to your computer and use it in GitHub Desktop.
Save ryanfb/b974f502939c27b3967607423e50e23f to your computer and use it in GitHub Desktop.
Auto-transcribe and burn subtitles for all videos without existing subtitles
for ext in avi mp4 mpg mkv; do
for i in *.${ext}; do
if [ ! -e "$(basename "$i" ".${ext}").srt" ]; then
echo "Transcribing: $i"
time whisperx "$i" --model large-v3 --language en --task transcribe --hf_token $HUGGINGFACE_TOKEN --compute_type int8 --chunk_size 5
echo "Burning subtitles: $i"
ffmpeg -i "$i" -vf subtitles="$(basename "$i" ".${ext}").srt" "$(basename "$i" ".${ext}")-burned.${ext}"
else
echo "Skipping: $i"
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment