Skip to content

Instantly share code, notes, and snippets.

@janreggie
Created April 26, 2026 09:07
Show Gist options
  • Select an option

  • Save janreggie/c415eead163d764fe1a35c297abd5ce9 to your computer and use it in GitHub Desktop.

Select an option

Save janreggie/c415eead163d764fe1a35c297abd5ce9 to your computer and use it in GitHub Desktop.
How to extract clips from videos and save them as memes

Suppose you download a video online:

# Feel free to choose shitty quality e.g., 360p.
yt-dlp -f 18 'https://www.youtube.com/...'

And then you can trim it

ffmpeg \
  -ss 00:02:47.500 -to 00:03:10.500 \
  -i 'What you just downloaded.mp4' 
'out.mp4'

If it's not in a language that others can understand, you can create subtitles using tools like HappyScribe to manually create .srt files.

And then you can burn the subtitles to the video:

# In here, I'm burning out.srt to out.mp4.
# I used a larger font size.
# BorderStyle=3 allows the text to have a solid-colored background,
# but only the text (and not, say, an entire rectangle).
ffmpeg -i 'out.mp4' \
  -vf "subtitles=filename=out.srt:force_style='Fontsize=24,BorderStyle=3'" \
  'out-sub.mp4'

For more details, check the ffmpeg Subtitles filter documentation and SubStation Alpha v4.0.0+ documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment