Created
March 6, 2019 09:50
-
-
Save 7sDream/436a6040f3db523955960a1bcd1878fe to your computer and use it in GitHub Desktop.
togif.sh
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 | |
if [ "$#" -lt 2 ]; then | |
echo "Usage: $0 videofile output fps width start duration" | |
exit 1 | |
fi | |
VIDEO=$1 | |
OUTPUT=$2 | |
FPS=$3 | |
WIDTH=$4 | |
START=$5 | |
DURATION=$6 | |
: ${FPS:=film} | |
: ${WIDTH:=-1} | |
: ${START:=0} | |
: ${DURATION:=0} | |
if [ "$VIDEO" = "--help" ]; then | |
echo "$0 video output fps width start duration" | |
exit 0 | |
fi | |
if [ "$DURATION" = "0" ]; then | |
DURATION="" | |
else | |
DURATION="-t $DURATION" | |
fi | |
ffmpeg -ss "$START" $DURATION -i "$VIDEO" -vf fps=$FPS,scale=$WIDTH:-1:flags=lanczos,palettegen palette.png | |
ffmpeg -ss "$START" $DURATION -i "$VIDEO" -i palette.png -filter_complex "fps=$FPS,scale=$WIDTH:-1:flags=lanczos[x];[x][1:v]paletteuse" $OUTPUT | |
rm palette.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A small script help me convert video to gif use ffmpeg.
Argumemts: