Skip to content

Instantly share code, notes, and snippets.

@alioguzhan
Created May 19, 2016 12:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save alioguzhan/3cc7a032ffce692ab386f7f3ad00c09d to your computer and use it in GitHub Desktop.
Bash script to create gif from vide with ffmpeg
#!/bin/sh
global_palette="/tmp/global_palette.png"
filters="fps=$5,scale=$6:-1:flags=lanczos"
ffmpeg -v error -ss $1 -t $2 -i $3 -vf "$filters,palettegen" -y $global_palette
ffmpeg -v error -ss $1 -t $2 -i $3 -i $global_palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $4
# Example Usage:
# start duration input file output file fps gif scale
# ----- -------- ---------- ----------- --- ---------
# ./gif.sh 00:30 10 input.mp4 output.gif 20 260
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment