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/0A1b2C3d4E5On macOS
- Launch the Terminal app somehow, such as by using Spotlight (press
Command+Spacethen begin typing “terminal” and pressReturnonce macOS gets it), double-clicking it in/Applications/Utilities, or clicking it in Launchpad. - 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 pressReturn. 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. - Install
yt-dlpandffmpegusing Homebrew by running the command shown below:brew install yt-dlp/taps/yt-dlp ffmpeg - Change to your Downloads folder (“make it the working directory”):
cd ~/Downloads
Note you can pressTabto let the shell try to auto-complete your commands. - 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.
- 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:
You’ll find the downloaded video in youryt-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/0AMkXUgtNDwDownloadsfolder.
On Windows
- Download the latest release of
yt-dlpfor Windows by clicking on the following link: https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp.exe. - Download the latest release of
ffmpegfor 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.7zarchive, 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). - Extract the
ffmpeg-git-….7zarchive 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 pressShift+F10to see the 7-Zip context menu. Open the extracted folder and navigate to thebinfolder to findffmpeg.exe. - Make a new folder anywhere, move
yt-dlp.exeandffmpeg.exeinto the new folder you just created (the name of the folder doesn’t really matter), and open the new folder you just created. - Hold down
Shifton your keyboard and right-click on any empty area in the folder, then select “Open in Terminal” or “Open PowerShell window here.” - 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.
- 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 foryt-dlp.exeandffmpeg.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.