Skip to content

Instantly share code, notes, and snippets.

@velipso
Created January 18, 2017 20:35
Show Gist options
  • Save velipso/46845074f6d5825ab90d833827ceeffd to your computer and use it in GitHub Desktop.
Save velipso/46845074f6d5825ab90d833827ceeffd to your computer and use it in GitHub Desktop.
Fish script to convert movies to GIFs using ffmpeg
#!/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