Skip to content

Instantly share code, notes, and snippets.

@vmrob vmrob/
Created Jun 18, 2014

What would you like to do?
Converts a video to a gif
#!/bin/bash -e
# Converts a video to a gif
if [ "$#" -ne 2 ]; then
echo "usage: ${0##*/} [input video] [output gif]"
exit 1
# finds width and height of $VIDEO expressed as 123x456
WIDTH_HEIGHT=$(ffprobe -loglevel warning -show_streams $VIDEO | grep -e "width\|height" | sed -E 's/(width|height)=//g' | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/x/g')
# converts the video
ffmpeg -i $VIDEO -s $WIDTH_HEIGHT -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $GIF
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.