#!/bin/sh

set -e

fps=30
width=1280
palette="palette.png"
filters="fps=${fps},scale=${width}:-1:flags=lanczos"

ffmpeg -i $1 -vf "palettegen" -y $palette
ffmpeg -i $1 -i $palette -lavfi "${filters} [x]; [x][1:v] paletteuse" -y $2
