Skip to content

Instantly share code, notes, and snippets.

@hancush
Created January 7, 2016 17:33
Show Gist options
  • Select an option

  • Save hancush/88ab796d0936c637f53a to your computer and use it in GitHub Desktop.

Select an option

Save hancush/88ab796d0936c637f53a to your computer and use it in GitHub Desktop.
#!/bin/sh
youtube-dl -o "_%(id)s.%(ext)s" $1
infile=$(ls | head -n1)
palette="/tmp/palette.png"
filters="fps=12,scale=500:-1:flags=lanczos"
ffmpeg -v warning -ss $2 -t $3 -i $infile -vf "$filters,palettegen=stats_mode=diff" -y $palette
ffmpeg -v warning -ss $2 -t $3 -i $infile -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse=dither=none" -y anim.gif
rm $infile
@hancush

hancush commented Jan 7, 2016

Copy link
Copy Markdown
Author

bastardized version of script here: http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html

@hancush

hancush commented Nov 22, 2016

Copy link
Copy Markdown
Author

other adjustable params (hard-coded, sry):

  • fps: frames per second, value directly correlated with gif quality
  • scale: width, in pixels, will scale gif proportionally

@hancush

hancush commented Nov 22, 2016

Copy link
Copy Markdown
Author

you gotta pip install youtube-dl also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment