Skip to content

Instantly share code, notes, and snippets.

@aniket91 aniket91/creategif.sh
Last active Feb 27, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.