Last active
February 27, 2018 15:30
-
-
Save aniket91/c08ad48b1968dbcfa48cdb72188e5bba to your computer and use it in GitHub Desktop.
Shell script to create a gif out of a video using ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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