Download Part of a YouTube Video

As of April 2022, this is the best way I know how to download part of a YouTube video. We’ll be working mostly in the command line, but don’t let that faze you—follow the steps below, and the whole process should be quick and painless.

TL;DR (for the technically inclined): Run the following command, replacing the timestamps with your own start and end points and the YouTube link with that of the video you want to download (you need to have both yt-dlp and ffmpeg installed):

yt-dlp --external-downloader ffmpeg --external-downloader-args "ffmpeg_i:-ss 00:01:23.00 -to 01:23:45.00" https://youtu.be/0A1b2C3d4E5

On macOS

  1. Launch the Terminal app somehow, such as by using Spotlight (press Command + Space then begin typing “terminal” and press Return once macOS gets it), double-clicking it in /Applications/Utilities, or clicking it in Launchpad.
  2. Install Homebrew if you don’t already have it by running the command shown on https://brew.sh/. The install script may ask for sudo (admin) privileges by prompting for your password, at which point you can just type it and press Return. Note you won’t see any visual feedback in Terminal while you type your password (it’s a security feature carried over from ancient times), but rest assured it’s receiving your input.
  3. Install yt-dlp and ffmpeg using Homebrew by running the command shown below:
    brew install yt-dlp/taps/yt-dlp ffmpeg
  4. Change to your Downloads folder (“make it the working directory”):
    cd ~/Downloads

    Note you can press Tab to let the shell try to auto-complete your commands.
  5. Find the timestamps for when you want the video to start and end. In the following command, for example, I’ll be downloading the YouTube video https://youtu.be/0AMkXUgtNDw from 00:36:53 to 00:38:46.
  6. Run the command shown below, replacing the example start and end points with your own timestamps and the YouTube link with that of the video you want to download:
    yt-dlp -f "bestvideo+bestaudio" --external-downloader ffmpeg --external-downloader-args "ffmpeg_i:-ss 00:36:53.00 -to 00:38:46.00" https://youtu.be/0AMkXUgtNDw
    You’ll find the downloaded video in your Downloads folder.

On Windows

  1. Download the latest release of yt-dlp for Windows by clicking on the following link: https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe.
  2. Download the latest release of ffmpeg for Windows by clicking on the following link: https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z. If you don’t have 7-Zip installed to extract the .7z archive, download and install the version suitable for your PC from https://www.7-zip.org/ (you can find whether you have a 32-bit or 64-bit OS by following this guide by Microsoft).
  3. Extract the ffmpeg-git-….7z archive by right-clicking it, hovering over the “7-Zip” item, then clicking “Extract Here.” Windows 11 users may need to click “Show more options” or press Shift + F10 to see the 7-Zip context menu. Open the extracted folder and navigate to the bin folder to find ffmpeg.exe.
  4. Make a new folder anywhere, move yt-dlp.exe and ffmpeg.exe into the new folder you just created (the name of the folder doesn’t really matter), and open the new folder you just created.
  5. Hold down Shift on your keyboard and right-click on any empty area in the folder, then select “Open in Terminal” or “Open PowerShell window here.”
  6. Find the timestamps for when you want the video to start and end. In the following command, for example, I’ll be downloading the YouTube video https://youtu.be/0AMkXUgtNDw from 00:36:53 to 00:38:46.
  7. Run the command shown below, replacing the example start and end points with your own timestamps and the YouTube link with that of the video you want to download:
    .\yt-dlp -f "bestvideo+bestaudio" --external-downloader ffmpeg --external-downloader-args "ffmpeg_i:-ss 00:36:53.00 -to 00:38:46.00" https://youtu.be/0AMkXUgtNDw

    You’ll find the downloaded video in the folder you created for yt-dlp.exe and ffmpeg.exe.

Note: YouTube encodes videos of HD resolution and higher using the VP9 codec and audio using the Opus codec, which your OS’s built-in media player might not know how to decode without an add-on. You could always install a video player like VLC to play the downloaded .webm file. If you want to convert the downloaded file into a more compatible codec and format such as H.264 (more compatible) or H.265 (more efficient) in an .mp4 or .mov container, you can use ffmpeg as shown below, replacing the input filename with the name of the downloaded file you want to convert and the output filename with the name you want to give the converted file.

Convert the VP9 and Opus-encoded .webm file into an H.264 and AAC-encoded .mp4 file (just replace .mp4 with .mov if you want a .mov file for some reason) on macOS:

ffmpeg -hwaccel auto -i "input-filename-replace-me.webm" -c:v libx264 -c:a aac -b:a 192k -movflags +faststart "output-filename-replace-me.mp4"

Convert the VP9 and Opus-encoded .webm file into an H.265 and AAC-encoded .mov file (same as above, .mp4 will work just fine instead of .mov if you want) on Windows:

.\ffmpeg -hwaccel auto -i "input-filename-replace-me.webm" -c:v libx265 -tag:v hvc1 -c:a aac -b:a 192k -movflags +faststart "output-filename-replace-me.mov"

And that’s it! Now you have a high quality copy of part of a YouTube video saved to your own computer.

This article was updated on December 20, 2024