Created
October 1, 2013 19:19
-
-
Save bjou/6783648 to your computer and use it in GitHub Desktop.
Script to sample frames and convert frames to gif using ffmpeg.
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/sh | |
# check arg inputs | |
verbose=false | |
while getopts "hi:o:s:d:p:v" opt; do | |
case $opt in | |
h) | |
echo "" | |
exit 1 | |
;; | |
i) | |
inFile=$OPTARG | |
;; | |
o) | |
outDir=$OPTARG | |
;; | |
s) | |
startTime=$OPTARG | |
;; | |
d) | |
duration=$OPTARG | |
;; | |
p) | |
storyPrefix=$OPTARG | |
;; | |
v) | |
verbose=true | |
;; | |
\?) | |
echo "Invalid option: -$OPTARG" >&2 | |
exit 1 | |
;; | |
:) | |
echo "Option -$OPTARG requires an argument." >&2 | |
exit 1 | |
;; | |
esac | |
done | |
if $verbose ; then | |
echo "ffmpeg -i ""$inFile"" -vf scale=iw/2:-1 -r 2 -ss $startTime -t $duration ""$outDir""/frames%3d.png" | |
fi | |
ffmpeg -i "$inFile" -vf scale=iw/2:-1 -r 2 -ss $startTime -t $duration "$outDir"/frames%3d.png | |
if $verbose ; then | |
echo "convert -delay 7 -loop 0 ""$outDir""/frames*.png ""$outDir""/""$storyPrefix""_animation.gif" | |
fi | |
convert -delay 7 -loop 0 "$outDir"/frames*.png "$outDir"/"$storyPrefix"_animation.gif | |
if $verbose ; then | |
echo "rm ""$outDir""/frames*.png" | |
fi | |
rm "$outDir"/frames*.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment