Created
February 17, 2026 10:19
-
-
Save angelyordanov/7b789748d19cff97f1634cb68286e561 to your computer and use it in GitHub Desktop.
Create gifs from mov
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Requirements: brew install ffmpeg gifsicle | |
| set -e | |
| if [ -z "$1" ]; then | |
| echo "Usage: gif-create.sh <input.mov>" | |
| exit 1 | |
| fi | |
| INPUT="$1" | |
| BASENAME="${INPUT%.*}" | |
| OUTPUT="${BASENAME}.gif" | |
| PALETTE=$(mktemp /tmp/palette_XXXXXX.png) | |
| trap "rm -f $PALETTE" EXIT | |
| echo "🎬 Converting: $INPUT → $OUTPUT" | |
| # Pass 1: Generate palette | |
| ffmpeg -y -i "$INPUT" -vf "fps=15,palettegen=max_colors=128" "$PALETTE" 2>/dev/null | |
| # Pass 2: Create GIF with palette | |
| ffmpeg -y -i "$INPUT" -i "$PALETTE" -lavfi "fps=15 [x]; [x][1:v] paletteuse=dither=floyd_steinberg" "$OUTPUT" 2>/dev/null | |
| # Pass 3: Compress with gifsicle | |
| gifsicle -O3 --lossy=80 "$OUTPUT" -o "$OUTPUT" | |
| INPUT_SIZE=$(stat -f%z "$INPUT" 2>/dev/null || stat -c%s "$INPUT" 2>/dev/null) | |
| OUTPUT_SIZE=$(stat -f%z "$OUTPUT" 2>/dev/null || stat -c%s "$OUTPUT" 2>/dev/null) | |
| echo "✅ Done: $OUTPUT" | |
| echo " Input: $(echo "scale=1; $INPUT_SIZE/1048576" | bc)MB" | |
| echo " Output: $(echo "scale=1; $OUTPUT_SIZE/1048576" | bc)MB" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment