docs(examples): Convert to GIF (ffmpeg) script

This commit is contained in:
Maas Lalani 2022-07-15 18:33:04 -04:00
parent 473cab8216
commit 00ba1f77a7
No known key found for this signature in database
GPG key ID: 5A6ED5CBF1A0A000

15
examples/convert-to-gif.sh Executable file
View file

@ -0,0 +1,15 @@
#!/bin/bash
# This script converts some video to a GIF. It prompts the user to select an
# video file with `gum filter` Set the frame rate, desired width, and max
# colors to use Then, converts the video to a GIF.
INPUT=$(gum filter --placeholder "Input file")
FRAMERATE=$(gum input --prompt "Frame rate: " --placeholder "Frame Rate" --prompt.foreground 240 --value "50")
WIDTH=$(gum input --prompt "Width: " --placeholder "Width" --prompt.foreground 240 --value "1200")
MAXCOLORS=$(gum input --prompt "Max Colors: " --placeholder "Max Colors" --prompt.foreground 240 --value "256")
BASENAME=$(basename "$INPUT")
BASENAME="${BASENAME%%.*}"
gum spin --title "Converting to GIF" -- ffmpeg -i "$INPUT" -vf "fps=$FRAMERATE,scale=$WIDTH:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=$MAXCOLORS[p];[s1][p]paletteuse" "$BASENAME.gif"