Skip to content

Instantly share code, notes, and snippets.

@tucan9389
Last active February 18, 2020 08:07
Show Gist options
  • Save tucan9389/f0a20ce94e84e42e11d05b55673aacd1 to your computer and use it in GitHub Desktop.
Save tucan9389/f0a20ce94e84e42e11d05b55673aacd1 to your computer and use it in GitHub Desktop.
This script converts video to gif by using ffmpeg
# Usage:
# command
# `sh gifconverter.sh /Users/canapio/Desktop/turtle_DEMO_004_4.MP4`
# on mac
# some configuration
width="240"
fps="12"
# path setup
video_path=$1
directory_path=`dirname "$1"`
file=`basename "$1"`
extension="${file##*.}"
filename="${file%.*}"
echo $extension
gif_path="${video_path%.*}.gif"
echo $gif_path
ffmpeg -y -i $video_path -vf fps=$fps,scale=$width:-1:flags=lanczos,palettegen palette.png;
ffmpeg -y -i $video_path -i palette.png -filter_complex "fps=$fps,scale=$width:-1:flags=lanczos[x];[x][1:v]paletteuse" $gif_path;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment