Skip to content

Instantly share code, notes, and snippets.

@maxrodrigo
Created October 15, 2020 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxrodrigo/f8a206d4a34c72475dc6acbed0bb8fe1 to your computer and use it in GitHub Desktop.
Save maxrodrigo/f8a206d4a34c72475dc6acbed0bb8fe1 to your computer and use it in GitHub Desktop.
Creates gif for the given youtube video
#!/usr/bin/env bash
# example: ./yt-2-gif.sh dQw4w9WgXcQ 1 3
VID=$1
SKIP_SECONDS=$2
TIME=$3
youtube-dl --no-progress -o ${VID} ${VID}
ffmpeg -y -v error -ss ${SKIP_SECONDS} -t ${TIME} \
-i "${VID}.mp4" \
-vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
-loop 0 "${VID}.gif"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment