The Meowgorithm Dotfiles, Collectors’ Edition
#!/usr/bin/env bash
#
# Convert video files to animated WebP.
#
# Primary path: ffmpeg decodes frames to a temp dir, then img2webp
# (from libwebp) assembles them. This works even with ffmpeg builds
# that lack the libwebp encoder (e.g. recent Homebrew ffmpeg).
# Fallback: ffmpeg's libwebp encoder, if available.
#
# Usage: to-webp.sh [options] <input> [output]
set -e
# Defaults
FPS=15
WIDTH=""
QUALITY=75
LOOP=0
COMPRESSION=6
START=""
DURATION=""
OVERWRITE=false
LOSSLESS=false
usage() {
cat <<'EOF'
Usage: to-webp.sh [options] <input> [output]
Options:
-f, --fps N Frames per second (default: 15)
-w, --width N Output width in px (height auto, keeps aspect)
-q, --quality N Quality 0-100 (default: 75)
-l, --loop N Loop count, 0=infinite (default: 0)
-c, --compression N Compression effort 0-6 (default: 6; higher=smaller)
-s, --start TIME Start time (seconds or HH:MM:SS)
-d, --duration TIME Max duration (seconds or HH:MM:SS)
--lossless Use lossless encoding (larger files)
-y, --yes Overwrite output without asking
-h, --help Show this help