Skip to content

Instantly share code, notes, and snippets.

@Calinou
Created June 4, 2018 21:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Calinou/697eeeecda4d15a0ef07842e1b97f418 to your computer and use it in GitHub Desktop.
Save Calinou/697eeeecda4d15a0ef07842e1b97f418 to your computer and use it in GitHub Desktop.
Render text overlays for use with the Blender Video Sequence Editor
#!/bin/bash
#
# Renders text captions for videos; targeted at Blender usage.
# Usage: ./render.sh
#
# Copyright © 2018 Hugo Locurcio
# Licensed under CC0 1.0 Universal: https://creativecommons.org/publicdomain/zero/1.0/
set -euo pipefail
IFS=$'\n\t'
# Read entries from a file (one per line)
texts_file="texts.txt"
echo "Removing old images…"
rm -f *.png
while read -r text; do
output="$(echo "$text" | sed "s/\\( \\|'\\|:\\)/_/g").png"
echo -e "Rendering \e[1m$text\e[0m…"
convert \
-size "1920x1080" \
xc:none \
-fill "hsla(250, 65%, 12%, 0.8)" \
-draw "rectangle 0,880,960,1000" \
-fill "white" \
-gravity "SouthWest" \
-font "Montserrat-SemiBold" \
-interword-spacing "18" \
-pointsize "56" \
-draw "text 85,105 \"${text^^}\"" \
"$output"
done < "$texts_file"
echo -e "\e[1;32mDone rendering.\e[0m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment