Created
January 18, 2017 20:35
-
-
Save velipso/46845074f6d5825ab90d833827ceeffd to your computer and use it in GitHub Desktop.
Fish script to convert movies to GIFs using ffmpeg
This file contains 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
#!/usr/local/bin/fish | |
# Usage: | |
# ./to-gif somefile.mp4 [more files] | |
# | |
# Converts to 'somefile.gif' | |
set palette /tmp/palette.png | |
# V--------V---- change these if you want :-) | |
set filters "fps=15,scale=320:-1:flags=lanczos" | |
for f in $argv | |
echo "Processing $f file..." | |
set tgt (echo $f | sed -E 's/\.[^.]*$/.gif/') | |
ffmpeg -v warning -i $f -vf "$filters,palettegen" -y $palette | |
or exit 1 | |
ffmpeg -v warning -i $f -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $tgt | |
or exit 1 | |
end | |
rm -f $palette |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment