static-captcha/run.sh

30 lines
673 B
Bash
Raw Normal View History

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