If you don't want to use something more composed like this, the main trick gifski is doing is using a two-pass approach to generate a palette for the gif. You can do this pretty easily with just ffmpeg / ffprobe. Here's my personal script I use for generation:
#!/bin/sh
SCALE=500
FPS=15
SCALEPROVIDED=false
for arg in "$@"
do
case $arg in
-s=*|--size=*)
SCALE="${arg#*=}"
SCALEPROVIDED=true
shift
;;
-f=*|--fps=*)
FPS="${arg#*=}"
shift
;;
esac
done
palette="/tmp/palette.png"
# Look at the width/height of the video
width=`ffprobe -v error -select_streams v:0 -show_entries stream=width -of csv=s=x:p=0 $1`
height=`ffprobe -v error -select_streams v:0 -show_entries stream=height -of csv=s=x:p=0 $1`
# Get the max
max=$(( width > height ? width : height))
# If we havent provided a scale, and the max size is lower than the default, set it to the lower value
if [ "$SCALEPROVIDED" == true ]
then
minScale=$SCALE
else
minScale=$(( SCALE < max ? SCALE : max))
fi
# Set our flags
filters="fps=$FPS,scale=$minScale:-1:flags=lanczos"
# If there's no name provided, output the same name as the input with gif as the extension
output=$2
if [ -z "$output" ]
then
output=${1%.*}.gif
fi
# Output our gif
ffmpeg -v error -i $1 -vf "$filters,palettegen=max_colors=256" -y $palette
ffmpeg -v error -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $output
echo created $output at ${minScale}px
Example usage is something like:
gif input.mov
But you can also optionally specify framerate, size, and output name:
aside: find it funny (genuinely), you describe this as "pretty easy" xD. ffmpeg is so impressive but so daunting from a cli perspective to me. how do you even know whats possible! I would never have imagined it could generate palettes