-
Download a Single Video (Default Quality):
yt-dlp "https://www.youtube.com/watch?v=VIDEO_ID_HERE"
This usually downloads the "best" available format that includes both video and audio pre-muxed, which might not be the highest resolution available.
-
Download Audio Only (as MP3):
yt-dlp -x --audio-format mp3 "VIDEO_URL"
-x or --extract-audio: Extract the audio track.
--audio-format mp3: Convert the extracted audio to MP3 format (requires FFmpeg). Other common formats: aac, m4a, opus, vorbis, wav.
-
List Available Formats:
yt-dlp -F "VIDEO_URL"
-F or --list-formats: Shows a table of all available video and audio streams with their format codes, resolution, codecs, filesize estimates, etc.
-
Download a Specific Format:
Look at the output of -F. Let's say you want video format code 299 (e.g., 1080p video-only) and audio format code 140 (e.g., m4a audio-only).
yt-dlp -f 299+140 "VIDEO_URL"
-f: Select format(s).
+: Tells yt-dlp to download the specified video and audio streams separately and then merge them (requires FFmpeg).
-
Download Best Available Quality (Separate Video + Audio):
This often gives you the highest resolution video and highest quality audio, which might be separate streams on platforms like YouTube.
yt-dlp -f bestvideo+bestaudio/best "VIDEO_URL"
bestvideo: Selects the best quality video-only stream.
bestaudio: Selects the best quality audio-only stream.
+: Merge them.
/best: If separate bestvideo and bestaudio streams aren't available or merging fails, fall back to the single best pre-muxed file.
-
Download Best Quality MP4 Video:
yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" "VIDEO_URL"
This tries to get the best MP4 video and best M4A audio, merge them (resulting in MP4), falls back to the best pre-muxed MP4, and finally falls back to any best format if MP4 isn't available.
-
Download an Entire Playlist:
Just provide the playlist URL. yt-dlp will download all videos sequentially.
yt-dlp "https://www.youtube.com/playlist?list=PLAYLIST_ID_HERE"
-
Specify Output Filename/Directory:
yt-dlp -o "Downloads/%(title)s [%(id)s].%(ext)s" "VIDEO_URL"
-o: Output template.
Downloads/: Puts the file in a subdirectory named "Downloads".
%(title)s: Inserts the video title.
%(id)s: Inserts the video ID.
%(ext)s: Inserts the file extension (e.g., mp4, webm, mp3).
- Many other template variables exist (e.g.,
%(playlist_title)s, %(playlist_index)s, %(upload_date)s). See yt-dlp --help for more.
-
Download Subtitles:
yt-dlp --write-auto-sub --sub-lang en "VIDEO_URL"
--write-sub: Download manually uploaded subtitles.
--write-auto-sub: Download automatically generated subtitles.
--sub-lang en: Specify desired language code(s) (e.g., en, es, fr). Use --list-subs to see available subs.
--embed-subs: Embed subtitles into the video file (if the container format supports it, like MKV or MP4). Often used with -f.
-
Use Cookies (for Private/Login-Required Videos):
# Export cookies from your browser (using an extension) to a file named 'cookies.txt'
yt-dlp --cookies cookies.txt "PRIVATE_VIDEO_URL"
# Or try letting yt-dlp extract them automatically (requires 'browser-cookie3' python package)
yt-dlp --cookies-from-browser chrome "PRIVATE_VIDEO_URL"
# Replace 'chrome' with 'firefox', 'edge', 'safari', etc.
Start with the simple examples and gradually add options as you need more specific control over the downloads.