Last active
March 2, 2023 09:48
-
-
Save mfehr/7b7a3a5410359566418e7ea62bc11be2 to your computer and use it in GitHub Desktop.
gifify.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
#!/usr/bin/env bash | |
# USAGE: gifify.sh <video> <start time in s> <duration in s> <desired FPS> <scale in px> | |
# | |
# Example: ./gifify yourvideo.mp4 3 [start time in seconds] 10 [duration in seconds] 15 [desired FPS] 600 [gif scale, expressed as desired width in pixel] | |
# | |
palette="/tmp/palette_$2_$3_$4_$5.png" | |
filters="fps=$4,scale=$5:-1:flags=lanczos" | |
ffmpeg -ss $2 -t $3 -i $1 -vf "$filters,palettegen" -y $palette | |
ffmpeg -ss $2 -t $3 -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y "output_$2_$3_$4_$5.gif" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment