Last active
June 19, 2022 11:38
-
-
Save fionn/09c8014d07befcb88a591a7f73d5fffe to your computer and use it in GitHub Desktop.
Make gifs from videos
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 | |
set -euo pipefail | |
if [ ! "$1" ]; then | |
echo "Usage: $0 start_time duration input" | |
exit 1 | |
fi | |
start_time=$1 | |
duration=$2 | |
input=$3 | |
scale=720 | |
output="$3_$1_$2_$scale.gif" | |
fps=12 | |
log_level="verbose" | |
filters="[0:v] fps=$fps,scale=$scale:-1:flags=lanczos,split [a][b];[a] palettegen [p];[b][p] paletteuse" | |
ffmpeg -v "$log_level" -ss "$start_time" -t "$duration" -i "$input" -filter_complex "$filters" "$output" | |
echo "$output" | |
# Useful optimisation: gifsicle -O3 --lossy=30 -o output.gif input.gif. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment