Skip to content

Instantly share code, notes, and snippets.

@Birch-san
Created March 5, 2023 01:08
Show Gist options
  • Save Birch-san/1f0e3acf4d91eb7cd3fd5f67cc18c623 to your computer and use it in GitHub Desktop.
Save Birch-san/1f0e3acf4d91eb7cd3fd5f67cc18c623 to your computer and use it in GitHub Desktop.
ffmpeg: side-by-side comparison video
#!/usr/bin/env bash
# makes a video like:
# https://twitter.com/Birchlabs/status/1632185133435437057
# expects folders with filenames such as:
# /home/birch/git/diffusers-play/out_dynthreshoff/00000.679566949.cfg07.50.png
i=0
CFG_COUNTER=''
FONT='fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf'
for file in /home/birch/git/diffusers-play/out_dynthreshoff/*.png; do
CFG="$(echo "$file" | sed 's/^.*cfg//; s/\.png$//')"
CFG_COUNTER="$CFG_COUNTER,drawtext=$FONT:text='CFG Scale=$CFG':fontcolor=white:fontsize=48:x=286:y=h-th-14:enable='between(n,$i,$i)'"
((i=i+1))
done
FPS=24
ffmpeg -y -framerate "$FPS" -pattern_type glob -i '/home/birch/git/diffusers-play/out_dynthreshoff/*.679566949.cfg*.*.png' -framerate "$FPS" -pattern_type glob -i '/home/birch/git/diffusers-play/out_dynthreshon/*.679566949.cfg*.*.m7.5.p0.999.png' -filter_complex "format=yuv420p,hstack,pad=width=1024:height=640:x=0:y=64:color=black,drawtext=$FONT:text='Standard CFG':fontcolor=white:fontsize=48:x=90:y=12,drawtext=$FONT:text='Latent Thresholding':fontcolor=white:fontsize=48:x=526:y=12$CFG_COUNTER,tpad=stop_mode=clone:stop_duration=5" -c:v libx264 -crf 20 -preset slow -movflags +faststart dynthresh.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment