Last active
May 25, 2021 03:57
-
-
Save ruofeidu/4b2b7592d7357e1e0f0faeac34a4cd07 to your computer and use it in GitHub Desktop.
gifit.sh
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
start_time=0:0 | |
duration=10 | |
# Windows Bash | |
palette="/c/python3/scripts/palette.png" | |
# Linux / Mac Bash | |
# palette="/tmp/palette.png" | |
filters="fps=15,scale=320:-1:flags=lanczos" | |
if (( $# == 0 )); then | |
echo "Usage: gifit <file-name> [optional duration] [optional start_time]" | |
elif (( $# == 2 )); then | |
duration=$2 | |
elif (( $# == 3 )); then | |
duration=$2 | |
start_time=$3 | |
fi | |
# Get base filename | |
filename="$1" | |
filename=${filename%%.*} | |
ffmpeg -v warning -ss $start_time -t $duration -i $filename.mp4 -vf "$filters,palettegen" -y $palette | |
ffmpeg -v warning -ss $start_time -t $duration -i $filename.mp4 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $filename.gif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment