Skip to content

Instantly share code, notes, and snippets.

@ttys3
Created July 21, 2023 11:49
Show Gist options
  • Save ttys3/e7933204610415c589c94076028bed1b to your computer and use it in GitHub Desktop.
Save ttys3/e7933204610415c589c94076028bed1b to your computer and use it in GitHub Desktop.
ffmpeg-gif.sh
#!/usr/bin/env bash
set -eou pipefail
if [ "$#" -ne 2 ]; then
echo "Usage: $0 input_file output_file"
exit 1
fi
input_file="$1"
output_file="$2"
if [ ! -f "$input_file" ]; then
echo "Error: Input file '$input_file' not found or not accessible."
exit 1
fi
# ref https://superuser.com/a/1695537
ffmpeg -y -i "$input_file" -filter_complex "fps=5,scale=1344:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=32[p];[s1][p]paletteuse=dither=bayer" "$output_file"
echo "GIF created successfully at $output_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment