Skip to content

Instantly share code, notes, and snippets.

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