Grabbing a short audio clip from a long YouTube video

If you only need a few seconds of audio out of a very long video, you don’t have to download the whole thing. This pulls just the slice you ask for.

What you need first

  • Python (which comes with pip, its installer). This is the only general-purpose piece; the next two are installed through it or alongside it.
  • yt-dlp, the downloader that does the actual work. Install it by running: pip install yt-dlp
  • ffmpeg, which yt-dlp uses to cut and convert the audio. On Windows the easiest install is: winget install Gyan.FFmpeg

After installing ffmpeg, close your terminal and open a fresh one so it picks up the change. Confirm both tools are ready with yt-dlp --version and ffmpeg -version. If each prints version info, you’re set.

The command

yt-dlp -x --audio-format mp3 --download-sections "*1:23:00-1:23:25" "PASTE_URL_HERE"

What the parts mean:

  • -x extracts the audio and discards the video.
  • --audio-format mp3 hands you an mp3.
  • --download-sections "*1:23:00-1:23:25" is the time window. The asterisk marks it as a time range, and the two timestamps are start and end in hours:minutes:seconds. Replace them with the spot you want.
  • The URL goes last, in quotes.

The mp3 saves to whatever folder your terminal is sitting in.

One tip: YouTube’s audio seek points sit roughly ten seconds apart, so the cut can land slightly wide of the timestamps you type. Pad the range by a few seconds on each end, then trim to the exact in and out points in your audio or video editor.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *