Skip to content

Instantly share code, notes, and snippets.

@YuanLiou
Created September 11, 2022 07:43
Show Gist options
  • Save YuanLiou/77432b769de277dfa1917317302652bd to your computer and use it in GitHub Desktop.
Save YuanLiou/77432b769de277dfa1917317302652bd to your computer and use it in GitHub Desktop.
FFMPEG convert video to gif
# Convert video to gif file.
# Usage: video2gif video_file (scale) (fps)
video2gif() {
ffmpeg -y -i "${1}" -vf fps=${3:-10},scale=${2:-320}:-1:flags=lanczos,palettegen "${1}.png"
ffmpeg -i "${1}" -i "${1}.png" -filter_complex "fps=${3:-10},scale=${2:-320}:-1:flags=lanczos[x];[x][1:v]paletteuse" "${1}".gif
rm "${1}.png"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment