automatically create subtitles with ImageMagick
bashscript
file generateSubs.sh:
#!/bin/bash
c=0
chap=0
echo Chapter $chap
while read p; do
if [ -n "$p" ]; then
# white sub:
convert -size 1920x1080 -pointsize 48 -gravity South -background transparent -font Arial -fill black -stroke black label:"$p" -blur 0x2 +repage -fill white -stroke none label:"$p" -composite $(printf %02d $chap)\_$(printf %02d $c)\_white.png
# black sub:
convert -size 1920x1080 -pointsize 48 -gravity South -background transparent -font Arial -fill white -stroke white label:"$p" -blur 0x2 +repage -fill black -stroke none label:"$p" -composite $(printf %02d $chap)\_$(printf %02d $c)\_black.png
c=$((c+1))
else
chap=$((chap+1))
c=0
echo Chapter $chap
fi
done
run script:
every line will produce a new subtitle image, an empty line begins a new chapter
- run it interactive:
./generateSubs.sh
- or pipe a given textfile:
cat subtitles.txt | ./generateSubs.sh