Created
October 8, 2016 11:16
-
-
Save fcjurado/fa02c65484696932a31ce9281bbc5dbc to your computer and use it in GitHub Desktop.
Converts a mp4 to gif in batch
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 | |
if [ ! -d "./converted" ]; then mkdir "./converted"; fi | |
if [ ! -d "./tmp" ]; then mkdir "./tmp"; fi | |
for i in $(find ./ -name '*.mp4') | |
do | |
for word in $i | |
do | |
case "$word" in | |
*converted* ) | |
;; | |
*tmp* ) | |
;; | |
* ) | |
filename=$(basename "$word") | |
ffmpeg -i $filename -r 4 'tmp/frame-%03d.jpg' | |
echo "converting ./tmp/$filename" | |
convert -delay 25 -loop 0 'tmp/*.jpg' "converted/$filename.gif" | |
rm -rf ./tmp/* | |
esac | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment