Created
February 9, 2024 20:22
-
-
Save genevera/d134c9fe97d5c8621bafa123f7cd63f3 to your computer and use it in GitHub Desktop.
mkgif shell function
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
################################################################################ | |
# makes a 15 fps gif of a video file of *any length* so be sure you trim first | |
################################################################################ | |
function mkgif { | |
local -r _mov="${1}"; | |
local -r _gif="${2:-${$(basename ${_mov})%%.*}}.gif"; | |
palette="/tmp/palette.png" | |
filters="fps=15,scale=320:-1:flags=lanczos" | |
ffmpeg -hide_banner -loglevel error -i "${_mov}" -vf "${filters},palettegen=stats_mode=diff" -y "${palette}"; | |
ffmpeg -hide_banner -loglevel info -i "${_mov}" -i "${palette}" -lavfi "${filters},paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" -y "${_gif}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment