#!/bin/sh test "$#" -eq 2 || exit 1 infile="$1" outfile="$2" avifile="$(mktemp --suffix=.avi)" ppmfile="$(mktemp --suffix=.ppm)" vktools="tools/Vulkan-Tools" magick "$infile" -strip "$ppmfile" "$vktools/build/cube/vkcube" --texture "$ppmfile" --width 100 --height 100 & vkcube_pid=$! sleep 3 wf-recorder -c huffyuv -y -f "$avifile" -g "$(swaymsg -t get_tree | jq -r 'recurse(.nodes[], .floating_nodes[]) | select(.name == "vkcube") | .rect| [.x+4,",",.y+4," ",.width-8,"x",.height-8] | join("")')" & recorder_pid=$! sleep 2 kill "$recorder_pid" kill "$vkcube_pid" ffmpeg -y -t 1.33 -i "$avifile" -filter_complex "[0:v]fps=20[v0],[v0]colorkey=0x00ff00,split[v1][v2];[v1]palettegen[p];[v2][p]paletteuse" "$outfile" rm "$avifile" "$ppmfile"