Created
September 29, 2022 13:59
-
-
Save meowgorithm/5bd66009db266adcbc378c2a75084bc3 to your computer and use it in GitHub Desktop.
Small GIFs with ffmpeg and bash
This file contains 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
#!/usr/bin/env bash | |
function makeGIF { | |
local input="$1" | |
local framerate="$2" | |
local width="$3" | |
local basename="$4" | |
local maxColors="$5" | |
# GIFs of 60fps videos have to be 50fps | |
if [[ $framerate == "60" ]]; then | |
framerate=50 | |
fi | |
if [[ $maxColors == "" ]]; then | |
maxColors=256 | |
fi | |
ffmpeg \ | |
-framerate $framerate \ | |
-i $input \ | |
-vf "fps=$framerate,scale=$width:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=${maxColors}[p];[s1][p]paletteuse" \ | |
"$basename".gif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment