-
-
Save intelguasoft/b9111e79267abc5b55765bb8c3202bd3 to your computer and use it in GitHub Desktop.
Simple command to turn videos into GIFs
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/bash | |
v2gif() { | |
# Based on https://engineering.giphy.com/how-to-make-gifs-with-ffmpeg/ | |
ffmpeg="" | |
filter="" | |
palettegen="palettegen" | |
paletteuse="paletteuse" | |
while getopts "w:f:is:t:" opt; do | |
case ${opt} in | |
# Start offset (seconds) | |
s) ffmpeg="${ffmpeg} -ss ${OPTARG}";; | |
# Duration (seconds) | |
t) ffmpeg="${ffmpeg} -t ${OPTARG}";; | |
# Width (height: -1 = keep exact aspect ratio, -2 = round to even number (important for many video codecs)) | |
w) filter="scale=w=${OPTARG}:h=-2,$filter";; | |
# FPS | |
f) filter="fps=${OPTARG},$filter";; | |
# Insane mode (256-colors per frame) | |
i) | |
palettegen="${palettegen}=stats_mode=single" | |
paletteuse="${paletteuse}=new=1" | |
;; | |
esac; | |
done | |
shift $(($OPTIND - 1)); | |
ffmpeg ${ffmpeg} -i "$1" -filter_complex "[0:v] ${filter}split [a][b];[a] ${palettegen} [p];[b][p] ${paletteuse}" "$1.gif" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment