Skip to content

Instantly share code, notes, and snippets.

@steverichey
Created July 13, 2018 14:16
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 steverichey/a5caa0baa5726b262faa36556c23597e to your computer and use it in GitHub Desktop.
Save steverichey/a5caa0baa5726b262faa36556c23597e to your computer and use it in GitHub Desktop.
GIF creation with some optimization options
#!/bin/sh
# this was created for an admittedly specialized purpose but has some neat settings i want to remember
palette="/tmp/palette.png"
cropped="/tmp/cropped.mp4"
width="275"
filters="fps=15,scale=${width}:-1:flags=lanczos"
ffmpeg -y -i $1 -vf "crop=${width}:${width}:10:10" $cropped
ffprobe -v quiet -print_format json -show_format -show_streams $cropped
ffmpeg -v warning -i $1 -vf "$filters,palettegen=stats_mode=diff" -y $palette
ffmpeg -i $cropped -i $palette -s 128x128 -ss 00:00:01.750 -t 00:00:00.965 -lavfi "$filters,paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" -y $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment