Skip to content

Instantly share code, notes, and snippets.

@antdking
Created November 4, 2021 11:09
Show Gist options
  • Save antdking/5bf1c09090f20b0f6a66d41b1157fbf6 to your computer and use it in GitHub Desktop.
Save antdking/5bf1c09090f20b0f6a66d41b1157fbf6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -Eeuo pipefail
video_file="${1}"
palette_file="$(mktemp --suffix=.png)"
output_file="${video_file%.*}.gif"
function cleanup() {
rm -f "${palette_file}"
}
trap cleanup EXIT
ffmpeg -y -i "${video_file}" -vf palettegen "${palette_file}"
ffmpeg -i "${video_file}" -i "${palette_file}" -filter_complex paletteuse -r 10 "${output_file}"
echo "${output_file}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment