Skip to content

Instantly share code, notes, and snippets.

@eduard-sukharev
Created October 30, 2018 10:31
Show Gist options
  • Save eduard-sukharev/9baa8b6d195db35cb9929528024fa5ac to your computer and use it in GitHub Desktop.
Save eduard-sukharev/9baa8b6d195db35cb9929528024fa5ac to your computer and use it in GitHub Desktop.
Convert video to gif
#!/bin/sh
file_in=${1:-"input.mp4"}
file_out=${2:-"output.gif"}
fps=${3:-20}
width=${4:-400}
ffmpeg -y -i $file_in -vf fps=$fps,scale=$width:-1:flags=lanczos,palettegen palette.png
ffmpeg -y -i $file_in -i palette.png -filter_complex "fps=$fps,scale=$width:-1:flags=lanczos[x];[x][1:v]paletteuse" $file_out
rm -f palette.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment