Skip to content

Instantly share code, notes, and snippets.

@myersjustinc
Created August 8, 2021 18:08
Show Gist options
  • Save myersjustinc/35eaa9b59e6af148b6b30118476bc60b to your computer and use it in GitHub Desktop.
Save myersjustinc/35eaa9b59e6af148b6b30118476bc60b to your computer and use it in GitHub Desktop.

Revisions

  1. myersjustinc created this gist Aug 8, 2021.
    26 changes: 26 additions & 0 deletions commands.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    $ export VIDEO_ID='e1zvhJRIM7M'
    $ export VIDEO_URL="https://www.youtube.com/watch?v=${VIDEO_ID}"
    $ export CLIP_START='4.85'
    $ export CLIP_LENGTH='5.33
    $ export OUTPUT_NAME='kiki'

    $ youtube-dl -F "${VIDEO_URL}"
    # Find the 240p video-only MP4. Note the format number at the beginning of
    # that line, which we'll refer to below as `${FORMAT}`.

    $ youtube-dl -f "${FORMAT}" -o '%(id)s.%(ext)s' "${VIDEO_URL}"

    $ ffmpeg \
    -y \
    -i "${VIDEO_ID}.mp4" \
    -vf "subtitles=${VIDEO_ID}.srt:force_style='Fontsize=24,Bold=1'" \
    -ss "${CLIP_START}" \
    -t "${CLIP_LENGTH}" \
    "${OUTPUT_NAME}.mp4"

    # With thanks to Giphy:
    # https://engineering.giphy.com/how-to-make-gifs-with-ffmpeg/
    $ ffmpeg \
    -i "${OUTPUT_NAME}.mp4" \
    -filter_complex "[0:v] fps=12,scale=-1:240,split [a][b];[a] palettegen [p];[b][p] paletteuse" \
    "${OUTPUT_NAME}.gif"
    13 changes: 13 additions & 0 deletions e1zvhJRIM7M.srt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    1
    00:00:05,000 --> 00:00:06,500
    I went down to the beach
    and saw Kiki

    2
    00:00:07,000 --> 00:00:08,250
    She was all like,
    "Unnhhhh..."

    3
    00:00:08,500 --> 00:00:10,000
    And I'm like, "Whatever!"