Created
February 10, 2022 23:36
-
-
Save dunn/6783ea68a9cd9d2cc31ad72b9c70e121 to your computer and use it in GitHub Desktop.
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/sh | |
start="${1}" | |
duration="${2}" | |
input="${3}" | |
output="${4}" | |
palette="$(pwd)/palette-tmp.png" | |
filters="fps=15,scale=800:-1:flags=lanczos" | |
palette_cmd="ffmpeg -v warning -ss \"${start}\" -t \"${duration}\" -i \"${input}\" -vf \"${filters},palettegen=stats_mode=diff\" -y \"${palette}\"" | |
echo | |
echo 'Generating palette...' | |
echo "${palette_cmd}" | |
eval "${palette_cmd}" | |
echo | |
gif_cmd="ffmpeg -v warning -ss \"${start}\" -t \"${duration}\" -i \"${input}\" -i \"${palette}\" -lavfi \"${filters} [x]; [x][1:v] paletteuse=dither=floyd_steinberg\" -y \"${output}\"" | |
echo 'Generating GIF...' | |
echo "${gif_cmd}" | |
eval "${gif_cmd}" | |
rm "${palette}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment