static-captcha/run.sh
2025-01-03 10:18:41 -07:00

30 lines
673 B
Bash
Executable File

#!/bin/bash
FPS=30
DURATION=5
COMPRESSION=40
X=400
Y=150
# Create the mask
convert \
-background none -fill black \
-pointsize 120 -size ${X}x${Y} -gravity center \
label:$1 mask.png
# Create large static image
convert -size 2000x${Y} canvas: +noise Random -monochrome -alpha off background.png
# Create video
ffmpeg -loglevel error -hide_banner -y -framerate $FPS -loop true -t $DURATION -i background.png -i mask.png \
-filter_complex "
[0] crop=x=n:w=${X}:h=${Y},split[bg][a];
[a] hflip,vflip [flip];
[1] alphaextract [mask];
[flip][mask] alphamerge [text];
[bg][text] overlay"\
-c:v libx264 -crf $COMPRESSION -an out.mp4
rm mask.png background.png