Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Make An Animated GIF With ffmpeg

This is the script I use to make animated gifs :

[] comepare this with the one that takes off black bars to see if there are any difference besides that functionality

bash
INPUT_PATH="input.mp4"
OUTPUT_PATH="output.gif"
WIDTH=440
FPS=10
CROP="crop=in_w:in_h:0:0,"

ffmpeg -i "${INPUT_PATH}" \
       -vf "${CROP}fps=${FPS},scale=${WIDTH}:-2:flags=lanczos,split[s0][s1];\
      [s0]palettegen=max_colors=64:reserve_transparent=0[p];\
      [s1][p]paletteuse" \
       -y "${OUTPUT_PATH}"

You can also run it with start and end times with the [TODO: Code shorthand span ] (start second) and [TODO: Code shorthand span ] (time to capture) flags. I don't keep those in my script because I've already cut the videos by that time.

bash
ffmpeg -i "${INPUT_PATH}" \
       -ss 2 \
       -t 3
       -vf "${CROP}fps=${FPS},scale=${WIDTH}:-2:flags=lanczos,split[s0][s1];\
      [s0]palettegen=max_colors=64:reserve_transparent=0[p];\
      [s1][p]paletteuse" \
       -y "${OUTPUT_PATH}"