#!/bin/zsh movieInput=$1 tmpFolder=$2 outName=$3 mkdir -p $tmpFolder ffmpeg -i $movieInput $tmpFolder/%03d.png for i in `ls $tmpFolder`; do j=`echo $i | sed s/\.png/.webp/` cwebp $tmpFolder/$i -o $tmpFolder/$j done webpmux `for i in \`ls $tmpFolder/*.webp\`; do echo -n "-frame $i +33+0+0+1+b "; done` `echo -n $4` -o $outName # To cheat a none looping animation, add the last frame again with a really # long timeout. A slightly higher value can be given then below but the below # value is already more than 2 days. # -frame last-frame.webp +9999999+0+0+1+b