I only learned about the yt-dlp project today. It started because my you-get couldn’t download a certain video, so I searched again and discovered yt-dlp.
yt-dlp is from youtube-dl, so many of the commands are the same. Before using it, you still need to install ffmpeg and Python.
For instructions on installing ffmpeg and Python, please refer to my previous tutorial: Windows 11 You-get Tutorial for Downloading Web Videos.
I downloaded the pre-packaged yt-dlp .exe file. This isn’t a graphical interface software; it’s essentially the environment packaged into the .exe file. You can simply add it to your environment variables to use it, avoiding potential errors from command-line installation.
Step 1: Download yt-dlp.exe
After downloading yt-dlp.exe, place it in the folder where you need to use it, and then configure the environment.
Step 2: Add yt-dlp.exe to environment variables
Right-click “This PC” and select “Properties”.
In the pop-up window, click “Advanced system settings”.
In the “System Properties” window, under the “Advanced” tab, click the “Environment Variables” button.
In the “System variables” list, find the “Path” variable.
In the “Edit Environment Variables” window, click “New,” then enter the complete folder path where yt-dlp.exe is located (e.g., mine is D:\f\test), and click “OK” to save the settings and exit.
Afterwards, you can directly use yt-dlp.exe commands in the command prompt window.
In other words, my yt-dlp.exe is located in the folder D:\f\test.
Step 3: Use PowerShell terminal software
Specific commands:
Default best video download command, this may not be in MP4 format:
yt-dlp -f best 视频地址
Similar to youtube-dl, there is also a command to download the default video:
yt-dlp -f "bv+ba/b" 视频
However, the video downloaded by this command will most likely be in WebM format.
Download the best MP4 and audio files and automatically merge them:
yt-dlp -f 'bv[ext=mp4]+ba[ext=m4a]' --embed-metadata --merge-output-format mp4 视频地址 #不带封面 yt-dlp -f 'bv[ext=mp4]+ba[ext=m4a]' --embed-metadata --embed-thumbnail --merge-output-format mp4 视频地址 #带封面
It mainly depends on the specific video; it may be the same as the default in best.
yt-dlp -F "视频地址"
This shows the specific information of the current video, such as its format.
For example, if I want to download audio and automatically convert it to MP3 format:
yt-dlp -f140 -x --audio-format mp3 视频格式
140 is the green ID number mentioned earlier.
To download specific video and audio IDs:
yt-dlp -f 299+140 视频地址
Download what you consider the best MP4 and audio formats. If the video is MP4, it will also have the mp4_dash parameter, and if the audio is M4A, it will also have the mp4a. parameter. The following command will automatically merge the audio into the video. This is what I use most often. I usually use it to download the best quality videos, which is to merge and download the best quality MP4 and audio.
yt-dlp -f 137+140 视频地址
Download the video and audio with the specified ID and force them to be merged into MP4 format:
yt-dlp -f "249+247" --merge-output-format mp4 视频地址
This is generally used to force a webm file to be merged into an mp4 format. Adding quotes makes it more stable, but it’s optional.
Download 1080p with audio:
yt-dlp -f 'bv[height=1080][ext=mp4]+ba[ext=m4a]' 视频地址
Download 4K with audio:
yt-dlp -f 'bv[height=2160][ext=mp4]+ba[ext=m4a]' --embed-metadata 视频地址
My frequently used commands:
yt-dlp -f best 视频地址 #默认最佳,我对视频要求不高的时候就用这个 yt-dlp -F "视频地址" #看具体信息 yt-dlp -f id+id 视频 #找最佳画质的mp4和最佳音质的音频
Other commonly used commands:
Download the entire list of videos:
yt-dlp 列表地址
Download with Cookie (I will write a separate article about this):
yt-dlp --cookies cookies.txt "视频地址" #这个是手动传递,需要cookies.txt具体路径 yt-dlp --cookies-from-browser chrome "视频地址" yt-dlp --cookies-from-browser chrome --cookies cookies.txt "视频地址" #这个是直接调用浏览器的cookies
If you encounter the error /yt-dlp/yt-dlp/issues/7271, you need to unlock your cookies first. Here’s how:
Completely close the browser. Then, unlock the browser using a command.
"C:\Program Files\Google\Chrome\Application\chrome.exe" --disable-features=LockProfileCookieDatabase
The above is the browser’s installation path. You can also change the shortcut:
Find the browser shortcut (right-click the browser icon -> Properties).
Add the parameter `–disable-features=LockProfileCookieDatabase` to the end of the “Target” field.
Click “Apply” and save, then open the browser.
For Google Chrome: Visit chrome://version/ and check if the command line contains the line `–disable-features=LockProfileCookieDatabase`.
If it does, the browser is unlocked successfully.
(Download with SOCKS5 included. I don’t need this because I’m using OpenWrt, which is already automatic.)
yt-dlp --proxy socks5://127.0.0.1:端口 视频地址
Download with age settings:
yt-dlp --age-limit 18 视频地址
I prefer using cookies to download age-restricted videos.
Download videos uploaded before a specific date:
yt-dlp --datebefore 20241210 列表地址
Download videos uploaded after a specific date:
yt-dlp --dateafter 20241210 列表地址
Download videos uploaded within the last month:
yt-dlp --dateafter now-1months 列表地址
Download videos within a specified date range, for example, from December 1, 2024 to December 10, 2024:
yt-dlp --dateafter 20241201 --datebefore 20241210 列表地址
Download some videos specified in the list:
yt-dlp --playlist-items 5,8,20 列表地址
help:
yt-dlp --help
Reference: https://github.com/yt-dlp/yt-dlp
If you encounter any problems, just ask the AI. For now, Doubao is recommended as a domestic solution.