Skip to content

Instantly share code, notes, and snippets.

@daikini
Forked from mzgoddard/awebp.sh
Created February 8, 2019 15:42
Show Gist options
  • Save daikini/f74081ea85cf2951d0a710409e3453d8 to your computer and use it in GitHub Desktop.
Save daikini/f74081ea85cf2951d0a710409e3453d8 to your computer and use it in GitHub Desktop.
Turn a movie into an animated webp.
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment