Last active
January 31, 2024 22:19
-
-
Save benjiao/9ad1aa3e936ba12ed8be5daea8cf05d0 to your computer and use it in GitHub Desktop.
mp4-to-gif
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 | |
#--- | |
# Converts all .mp4 files in a directory to GIF | |
# NOTE: Filenames must have no spaces | |
#--- | |
mkdir -p output | |
palette="/tmp/palette.png" | |
for i in *.mp4 | |
do | |
f=$(basename -- ${i%.*}) | |
echo "Working on $f..." | |
filters="fps=6,scale=680:-1:flags=lanczos" | |
ffmpeg -v warning -i "$f.mp4" -vf "$filters,palettegen=64" -y "$palette" | |
ffmpeg -v warning -i "$f.mp4" -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse=dither=floyd_steinberg" -y "output/$f.gif" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment