generate palette
ffmpeg -i whiteBG.png -vf "palettegen=max_colors=256:reserve_transparent=1" -frames:v 1 palette.png

make palette 16x16
ffmpeg -i palette.png -vf "scale=16:16" -frames:v 1 palette_16x16.png

use palette
ffmpeg -y -f concat -safe 0 -i $filelist -i palette.png -filter_complex "[0:v]scale=$scale:-1,setsar=1[vid];[vid][1:v]paletteuse" output_%04d.png
