Skip to content

Instantly share code, notes, and snippets.

@maxrodrigo
Created October 15, 2020 14:38
Show Gist options
  • Save maxrodrigo/f8a206d4a34c72475dc6acbed0bb8fe1 to your computer and use it in GitHub Desktop.
Save maxrodrigo/f8a206d4a34c72475dc6acbed0bb8fe1 to your computer and use it in GitHub Desktop.

Revisions

  1. maxrodrigo created this gist Oct 15, 2020.
    13 changes: 13 additions & 0 deletions youtube-to-gif.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/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"