How to download a specific part of YouTube video?

I don’t know of a way to do this.

Normally I just use yt-dlp to download the whole video and rencode with ffmpeg, using the -ss and -t options. Eg:

  1. Download

    yt-dlp https://example.com
    
  2. Re-encode from a particular time code to webm format.
    Cut a particular segment from the video.

    ffmpeg -ss 00:00:06 -i input.mp4 -t 00:00:21 \
           -c:v libvpx -crf 4 -b:v 1M -c:a libvorbis output.webm
    

    Alternatively, instead of ogg/webm you might want to use a better codec like H264, or H265.

    Or, copy without re-encoding:

    ffmpeg -i input.mp4 \
           -c:v copy -c:a copy output.webm
    
  3. Alternatively use -an to strip audio from the video