YT-DLP Common Commands
In some cases, downloading YouTube videos is a legal thing to do. I just had a situation where I'd lost the original file to one of my uploaded videos. I wanted to make sure I had a copy, so I used YT-DLP to get the video.
For work I am also asked to get content from videos, and it's always like pulling teeth to try and get the original video from the client.
Either that, or it's so big, it just wouldn't be practical to use anything to upload/download it in a reasonable amount of time. I often ask the client if I can just download the video off YouTube if they're fine with it to save time and money. They always say yes.
For those moments, I use YT-DLP, which installs on my windows 11 machine and runs from the command line.
Install YT-DLP along with FFMPEG.exe in my videos folder.
Next I hit WIN+R and in the run box, I type CMD and hit enter to get the command prompt window. On the command line, I change directories to the Videos directory by typing:
cd Videos
Now I am in the Videos folder.
Here are the commands that I use most often:
Quick download a video
I use this command when I don't care about customizing the settings. It just downloads the video and I go on with my day.
yt-dlp "VIDEO-URL-HERE"
yt-dlp.exe "https://www.youtube.com/watch?v=Aq5WXmQQooo"
This is for the Rick Roll video if I had permission to download it. Since I don't, I'm just using this to show you what the command would look like.
Here's one that is a bit more complicated, but it's what I use 99% of the time:
yt-dlp -f "bv*+ba/b" --embed-thumbnail --embed-subs --embed-metadata --merge-output-format mp4 "https://www.youtube.com/watch?v=Aq5WXmQQooo" --output "%(channel)s/%(title)s"
Let me break it down:
yt-dlp
— the command-line video downloader.- *`-f "bv+ba/b"`**
bv*
= best video stream available.+ba
= adds the best audio stream./b
= fallback to best single stream if separate tracks aren’t available.- Result: downloads the highest quality video and audio automatically.
--embed-thumbnail
— inserts the video’s thumbnail image into the final MP4 file.--embed-subs
— downloads and embeds subtitles if available.--embed-metadata
— writes metadata (title, uploader, date, etc.) into the video file.--merge-output-format mp4
— combines audio and video into one MP4 file."https://www.youtube.com/watch?v=Aq5WXmQQooo"
— the direct YouTube video URL.--output "%(channel)s/%(title)s"
- Saves files using this folder/file pattern:
- Folder = channel name.
- File = video title.
When I only need the audio
This is used most when a client wants a recording of a presentation they did. They ask for just the audio, and I download it this way:
Audio with Thumbnail
yt-dlp -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 --embed-thumbnail https://www.youtube.com/watch?v=Aq5WXmQQooo --output "%(channel)s/%(title)s"
Here's the breakdown:
yt-dlp
— the command-line tool for downloading and converting media.-f bestaudio
— selects the best available audio-only stream from the source.--extract-audio
— extracts the audio track from the downloaded file.--audio-format mp3
— converts the extracted audio to MP3 format.--audio-quality 0
— sets the highest audio quality (0 = best, 9 = worst).--embed-thumbnail
— embeds the video’s thumbnail as the MP3 album cover.https://www.youtube.com/watch?v=Aq5WXmQQooo
— the YouTube video URL to download from.--output "%(channel)s/%(title)s"
- Saves files in a structured layout:
- Folder = channel name.
- File = video title.
When I need to get an entire playlist
yt-dlp --ignore-errors --format bestaudio --extract-audio --audio-format flac --audio-quality 320K --output "%(channel)s/%(playlist)s/%(title)s" --yes-playlist --embed-thumbnail "https://www.youtube.com/watch?v=2l51wyMM9hs&list=PLVbxVQf7e2KRz1J34jFf7jDJFDT9lvnQ9" --output "%(channel)s/%(playlist)s/%(title)s"
yt-dlp
— command-line downloader for YouTube and other media sources.--ignore-errors
— skips over any videos that fail to download, continuing with the rest of the playlist.--format bestaudio
— selects the highest quality audio stream available.--extract-audio
— extracts only the audio portion of each video.--audio-format flac
— converts the audio to FLAC, a lossless format.--audio-quality 320K
— sets the target bitrate to 320 kbps (used for compatible formats).--output "%(channel)s/%(playlist)s/%(title)s"
- Defines the file save structure:
- Folder = channel name.
- Subfolder = playlist name.
- File = video title.
- Note: this parameter appears twice in the command; the second occurrence is redundant but harmless.
--yes-playlist
— downloads the entire playlist, not just the single linked video.--embed-thumbnail
— embeds the video thumbnail as the cover image in the resulting audio file."https://www.youtube.com/watch?v=2l51wyMM9hs&list=PLVbxVQf7e2KRz1J34jFf7jDJFDT9lvnQ9"
— the YouTube playlist URL to download.
Create a text list and then download after edits
Finally, there was one time when someone wanted a list of all the videos on their channel, and then a download of that
yt-dlp.exe --flat-playlist --print "%(webpage_url)s" "https://www.youtube.com/watch?v=2l51wyMM9hs&list=PLVbxVQf7e2KRz1J34jFf7jDJFDT9lvnQ9" > rickrolled.txt
yt-dlp.exe
— Windows executable version of the YouTube downloader.--flat-playlist
— lists all videos in the playlist without downloading any of them.--print "%(webpage_url)s"
— prints the URL of each video in the playlist to standard output."https://www.youtube.com/watch?v=2l51wyMM9hs&list=PLVbxVQf7e2KRz1J34jFf7jDJFDT9lvnQ9"
— the YouTube playlist URL to process.> rickrolled.txt
— redirects the printed output (the list of URLs) into a text file namedrickrolled.txt
.
Result:
Creates a text file containing all video URLs from the specified YouTube playlist, one per line.
And then to download the videos in the list after removing ones in the list that the client didn't want:
yt-dlp.exe -a rickrolled.txt -f bestaudio --extract-audio --audio-format mp3 --audio-quality 0 --embed-thumbnail -o "%(channel)s/%(title)s [%(id)s].%(ext)s"
yt-dlp.exe
— Windows version of the YouTube downloader.-a rickrolled.txt
— reads video URLs from the filerickrolled.txt
and processes them one by one.-f bestaudio
— selects the best available audio-only stream for each video.--extract-audio
— extracts only the audio track from the downloaded video.--audio-format mp3
— converts the extracted audio to MP3 format.--audio-quality 0
— sets the highest variable bitrate (VBR) quality for MP3 encoding.--embed-thumbnail
— embeds the video’s thumbnail image as the MP3 album cover.-o "%(channel)s/%(title)s [%(id)s].%(ext)s"
- Defines how files are saved:
- Folder = channel name.
- File name = video title followed by its YouTube ID in brackets.
- Extension = determined automatically (e.g.,
.mp3
).
Result:
Downloads all videos listed in rickrolled.txt
, extracts and converts them into high-quality MP3 files with embedded thumbnails, organized by channel.
I use YT-DLP for only downloading the videos that are my own, or that I have written client permission to download. If any suit in a legal department comes after me, I can prove that what I was doing was just making a backup of my content for for a client that had undisputed legal claim to the content.