Created
January 7, 2016 17:33
-
-
Save hancush/88ab796d0936c637f53a to your computer and use it in GitHub Desktop.
This file contains hidden or 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/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 |
Author
Author
bastardized version of script here: http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html
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
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
to run:
save vidgif.sh
from directory containing vidgif.sh:
bash vidgif.sh youtube_url start_time gif_lengthwhere start time is MM:SS, gif length is time in whole seconds
script downloads youtube video, creates color palette then gif with that palette to ensure highest quality via ffmpeg, writes output to anim.gif, deletes video file