updates from the article

This commit is contained in:
Oliver Atkinson 2025-01-03 10:18:41 -07:00
parent 11cdf2fdc2
commit 9c9ac98135
2 changed files with 25 additions and 4 deletions

17
merge.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/bash
# Split the frames out
mkdir frames
ffmpeg -i $1 frames/frame%04d.png
# Change the white -> transparent
mkdir chromakeyed
for f in frames/*
do
convert $f -fuzz 50% -transparent white chromakeyed/$(basename $f)
done
# Merge all the frames into one image
convert chromakeyed/* -background red -flatten flat.png
rm -r frames chromakeyed

12
run.sh
View File

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