-
-
Save mariomartinezsz/4463888 to your computer and use it in GitHub Desktop.
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/sh | |
if [ -z "$6" ] | |
then | |
echo "Usage: `basename $0` [-n] <filename> <start time> <duration> <scale to width> <framestep> <resultname.gif>\n-n — turn off subtitles" | |
else | |
OPT= | |
if [ "$1" = "-n" ] | |
then | |
OPT="-nosub -noautosub" | |
shift | |
fi | |
STEP=$5 | |
TEMP=`mktemp -d /tmp/mpgifXXXXXX` | |
FILENAME=$( readlink -f "$1" ) | |
cd "$TEMP" | |
FPS=$( mplayer "$FILENAME" $OPT -ss $2 -endpos $3 -vf scale=$4:-2,framestep=$5 -nosound -vo png:z=9 2>&1 | sed -n 's/.* \([0-9]*\)\.[0-9]* fps .*/\1/p' ) | |
DELAY=$(( 100 * STEP / FPS )) | |
xdg-open "$TEMP" | |
read -p "Now remove any excessive frames and press Enter to combine them to a nice gif." null | |
convert -delay $DELAY "$TEMP/*.png" -layers optimize-transparency "$6" | |
rm -rf "$TEMP" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment