Skip to content

Instantly share code, notes, and snippets.

@aniket91
Last active February 27, 2018 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniket91/c08ad48b1968dbcfa48cdb72188e5bba to your computer and use it in GitHub Desktop.
Save aniket91/c08ad48b1968dbcfa48cdb72188e5bba to your computer and use it in GitHub Desktop.
Shell script to create a gif out of a video using ffmpeg
#!/bin/bash
#----------------------------------------------------
# Author : athakur
# Version : 1.0
# Create Date : 27/02/2018
# Update Date : 27/02/2018
# Description : Create gif from a video
# Sample usage : ./creategif.sh input.mp4 output.gif
# ffmpeg static build can be downloaded from https://johnvansickle.com/ffmpeg/
#----------------------------------------------------
echo "Converting $1 to $2"
if [ -z "$1" ] || [ -z "$2" ]
then
echo "Incorrect arguments supplied. Format - ./creategif.sh input.mp4 output.gif"
exit
fi
palette="/tmp/palette.png"
filters="fps=10,scale=1024:-1:flags=lanczos"
ffmpeg -v warning -i "$1" -vf "$filters,palettegen" -y "$palette"
ffmpeg -v warning -i "$1" -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y "$2"
echo "Completed gif creation"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment