#!/bin/bash
# contact sheet: crop the caption area of each frame, label it, stack
cd "$(dirname "$0")"
names="A-mukta A-khula A-tiro A-yantramanav A-baloo2 A-inter-only X-mukta-subtitles-filter B-inter-with-system-fallback C-mukta-named-not-found"
labels=("Mukta" "Khula" "Tiro Devanagari Hindi" "Yantramanav" "Baloo 2" "Inter only (no Devanagari font on the system)" "Control - Mukta via the subtitles filter (broken)" "Inter, system has Noto Sans Devanagari" "Mukta named, not found, system has Noto")
args=(); fc=""; i=0
for n in $names; do args+=(-i frames/$n.png); l="${labels[$i]}"
  fc+="[$i:v]crop=1280:170:0:190,pad=1280:214:0:44:color=0x0a121b,drawtext=fontfile=fonts/Inter-Bold.ttf:text='$l':fontsize=30:fontcolor=white:x=16:y=6[v$i];"; i=$((i+1)); done
in=""; for ((k=0;k<i;k++)); do in+="[v$k]"; done
ffmpeg -hide_banner -loglevel error -y "${args[@]}" -filter_complex "${fc}${in}vstack=inputs=$i" -frames:v 1 frames/sheet.png; echo "sheet exit=$?"
