Created
October 10, 2017 16:43
-
-
Save mxbees/789154b661d1525f840ce043b665a398 to your computer and use it in GitHub Desktop.
A little script I use for making gifs.
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
#!/bin/bash | |
for i in "$@" | |
do | |
case $i in | |
-f=*) | |
frames=$(echo "${i#*=}") | |
shift | |
;; | |
-w=*) | |
width=$(echo "${i#*=}") | |
shift | |
;; | |
-b=*) | |
start=$(echo "${i#*=}") | |
shift | |
;; | |
-d=*) | |
duration=$(echo "${i#*=}") | |
shift | |
;; | |
-h) | |
echo " | |
use -f=* for number of frames | |
-w=* for the width | |
-b=* for the starting timestamp (00:00:00) | |
-d=* for number of seconds | |
-h for this menu | |
" | |
shift | |
;; | |
?) | |
echo "hit -h for help" | |
shift | |
;; | |
esac | |
done | |
video=$1 | |
gif=$2 | |
extract () { | |
ffmpeg -i $video -r $frames/1 -ss $start -t $duration -vf scale=$width:-1 %03d.png | |
echo "$video $frames $start $duration $width" | |
} | |
mk_gif () { | |
convert -ordered-dither o8x8,16 -delay 12 *.png -coalesce -layers OptimizeTransparency +map $gif.gif | |
} | |
for i in "$@" | |
do | |
case $i in | |
gif) | |
extract $video $frames $start $duration $width | |
mk_gif $gif | |
shift | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment