Installation
yt-dlp is a feature-rich command-line audio/video downloader forked from youtube-dl. It supports thousands of sites and is actively maintained.
# Using winget (built-in on Windows 10+)
winget install yt-dlp
# Or using Scoop
scoop install yt-dlp
# Or download the .exe from GitHub Releases
# https://github.com/yt-dlp/yt-dlp/releases/latestbrew install yt-dlp# Package manager
sudo apt install yt-dlp # Debian/Ubuntu
sudo pacman -S yt-dlp # Arch
sudo dnf install yt-dlp # Fedora
# Or download the binary directly
sudo curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp
sudo chmod a+rx /usr/local/bin/yt-dlppip install yt-dlp
# Update later:
pip install -U yt-dlp
# Or using pipx for isolated install:
pipx install yt-dlpyt-dlp --version
yt-dlp -U # Update to latest versionBasic Usage
The simplest command is just yt-dlp URL. By default it downloads the best quality available.
yt-dlp "https://www.youtube.com/watch?v=dQw4w9WgXcQ"yt-dlp -F "https://www.youtube.com/watch?v=VIDEO_ID"
# Shows a table like:
# ID EXT RESOLUTION FPS β FILESIZE TBR PROTO VCODEC ACODEC
# 140 m4a audio only β 3.5MiB 128k https audio mp4a.40.2
# 247 webm 1280x720 30 β 12.3MiB 800k https vp9 none
# 137 mp4 1920x1080 30 β 25.1MiB 2500k https avc1 none
# 313 webm 3840x2160 30 β 95.0MiB 8000k https vp9 noneyt-dlp -s "URL" # Simulate (no download)
yt-dlp --print filename "URL" # Show what file would be created
yt-dlp -j "URL" # Print full JSON metadataFormats & Quality
The -f flag is your primary tool for controlling download quality. This is what you'll use most often.
# Best video+audio up to 1080p
yt-dlp -f "bestvideo[height<=1080]+bestaudio/best" "URL"
# Best video+audio up to 720p
yt-dlp -f "bestvideo[height<=720]+bestaudio/best" "URL"
# Best video+audio up to 480p
yt-dlp -f "bestvideo[height<=480]+bestaudio/best" "URL"
# Best video+audio up to 4K (2160p)
yt-dlp -f "bestvideo[height<=2160]+bestaudio/best" "URL"# Best MP4 video + M4A audio (no re-encoding)
yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]" "URL"
# Or merge everything into mp4 container
yt-dlp --merge-output-format mp4 "URL"
# Best mp4 at max 1080p
yt-dlp -f "bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]" "URL"# First run -F to find the IDs, then:
yt-dlp -f 137+140 "URL" # video ID 137 + audio ID 140
yt-dlp -f 313+251 "URL" # 4K VP9 + Opus audioFormat Selection Syntax
| Syntax | Description |
|---|---|
best | Best single file (video+audio combined) |
bestvideo+bestaudio | Best separate streams, merged (default) |
worst | Lowest quality single file |
bestaudio | Best audio-only stream |
[height<=720] | Filter: max 720p height |
[ext=mp4] | Filter: only mp4 container |
[fps<=30] | Filter: max 30fps |
[vcodec^=avc1] | Filter: H.264 video codec |
[filesize<50M] | Filter: file under 50MB |
f1/f2 | Fallback: try f1 first, then f2 |
# Prefer H.264 codec (better device compatibility)
yt-dlp -f "bestvideo[vcodec^=avc1]+bestaudio/best" "URL"
# Prefer AV1 codec (better quality-to-size)
yt-dlp -f "bestvideo[vcodec^=av01]+bestaudio/best" "URL"
# Best quality under 100MB
yt-dlp -f "best[filesize<100M]" "URL"
# 60fps preferred
yt-dlp -f "bestvideo[fps>=50]+bestaudio/best" "URL"Audio Extraction
Extract just the audio track from any video. Perfect for music, podcasts, and lectures.
# Download & convert to MP3 at best quality
yt-dlp -x --audio-format mp3 "URL"
# Specify quality (0=best, 10=worst)
yt-dlp -x --audio-format mp3 --audio-quality 0 "URL"
# MP3 at 320kbps
yt-dlp -x --audio-format mp3 --audio-quality 320K "URL"yt-dlp -x --audio-format opus "URL" # Opus (smallest)
yt-dlp -x --audio-format flac "URL" # FLAC (lossless)
yt-dlp -x --audio-format m4a "URL" # M4A / AAC
yt-dlp -x --audio-format wav "URL" # WAV (uncompressed)
yt-dlp -x "URL" # Keep original (no conversion)Output & Naming
Control where files are saved and how they're named using the -o template system.
# Save to specific folder with title
yt-dlp -o "~/Downloads/%(title)s.%(ext)s" "URL"
# Include uploader and date
yt-dlp -o "%(uploader)s/%(upload_date)s - %(title)s.%(ext)s" "URL"
# Include resolution in filename
yt-dlp -o "%(title)s [%(resolution)s].%(ext)s" "URL"
# Playlist: folder + numbered files
yt-dlp -o "%(playlist)s/%(playlist_index)03d - %(title)s.%(ext)s" "URL"
# Channel archive: channel β year β title
yt-dlp -o "%(channel)s/%(upload_date>%Y)s/%(title)s.%(ext)s" "URL"Template Variables
| Variable | Description | Example |
|---|---|---|
%(title)s | Video title | My Video |
%(id)s | Video ID | dQw4w9WgXcQ |
%(ext)s | File extension | mp4 |
%(uploader)s | Uploader name | Rick Astley |
%(channel)s | Channel name | Rick Astley |
%(upload_date)s | Upload date | 20091025 |
%(upload_date>%Y)s | Upload year | 2009 |
%(resolution)s | Resolution | 1920x1080 |
%(duration)s | Duration (seconds) | 212 |
%(playlist)s | Playlist name | My Playlist |
%(playlist_index)s | Index in playlist | 1, 2, 3β¦ |
yt-dlp --restrict-filenames -o "%(title)s.%(ext)s" "URL"
# Replaces spaces β underscores, removes special charsPlaylists & Channels
# Full playlist
yt-dlp "https://www.youtube.com/playlist?list=PLxxxxxx"
# Items 3 through 10
yt-dlp --playlist-start 3 --playlist-end 10 "PLAYLIST_URL"
# Only items 1, 3, 5, 7
yt-dlp -I 1,3,5,7 "PLAYLIST_URL"
# Last 5 videos
yt-dlp -I -5: "PLAYLIST_URL"
# Every other video
yt-dlp -I ::2 "PLAYLIST_URL"
# Reverse order
yt-dlp --playlist-reverse "PLAYLIST_URL"# All videos from channel
yt-dlp "https://www.youtube.com/@ChannelName/videos"
# Only after a date
yt-dlp --dateafter 20240101 "CHANNEL_URL"
# Date range
yt-dlp --dateafter 20240601 --datebefore 20241231 "CHANNEL_URL"
# Skip already-downloaded (essential for recurring runs)
yt-dlp --download-archive archive.txt "CHANNEL_URL"# Don't download playlist when URL has &list= param
yt-dlp --no-playlist "URL_WITH_PLAYLIST_PARAM"
# Force treat URL as playlist
yt-dlp --yes-playlist "URL"Subtitles
# All available subs
yt-dlp --write-subs "URL"
# Specific language
yt-dlp --write-subs --sub-langs en "URL"
# Multiple languages
yt-dlp --write-subs --sub-langs "en,es,fr" "URL"
# Auto-generated subtitles
yt-dlp --write-auto-subs --sub-langs en "URL"
# Embed subs into video (MP4/MKV)
yt-dlp --write-subs --embed-subs --sub-langs en "URL"
# Download ONLY subtitles
yt-dlp --write-subs --skip-download --sub-langs en "URL"
# List available subs
yt-dlp --list-subs "URL"
# Convert subtitle format
yt-dlp --write-subs --convert-subs srt "URL"Authentication
Access age-restricted, members-only, or private content.
yt-dlp --cookies-from-browser chrome "URL"
yt-dlp --cookies-from-browser firefox "URL"
yt-dlp --cookies-from-browser edge "URL"
yt-dlp --cookies-from-browser safari "URL"
# Or use a cookies.txt file
yt-dlp --cookies cookies.txt "URL"yt-dlp -u USERNAME -p PASSWORD "URL"Speed & Network
# Limit speed
yt-dlp -r 5M "URL" # Max 5 MB/s
# Multiple connections (faster!)
yt-dlp -N 4 "URL" # 4 concurrent fragments
# Proxy
yt-dlp --proxy socks5://127.0.0.1:1080 "URL"
# Geo-bypass
yt-dlp --geo-bypass-country US "URL"
# Retry on failure
yt-dlp --retries 10 --fragment-retries 10 "URL"
# Resume partial download
yt-dlp -c "URL"Post-Processing
# Download a section (requires ffmpeg)
yt-dlp --download-sections "*00:01:30-00:03:45" "URL"
# From 2 minutes to end
yt-dlp --download-sections "*00:02:00-inf" "URL"
# First 60 seconds
yt-dlp --download-sections "*00:00:00-00:01:00" "URL"# Re-encode to MP4
yt-dlp --recode-video mp4 "URL"
# Merge output to specific container
yt-dlp --merge-output-format mkv "URL"
# Split by chapters
yt-dlp --split-chapters "URL"
# Split with naming
yt-dlp --split-chapters -o "chapter:%(section_title)s.%(ext)s" "URL"Batch Downloads
# urls.txt β one URL per line
yt-dlp -a urls.txt
# With options
yt-dlp -a urls.txt -f "bestvideo[height<=1080]+bestaudio"
# Multiple URLs inline
yt-dlp "URL1" "URL2" "URL3"# Only videos under 10 minutes
yt-dlp --match-filter "duration < 600" "PLAYLIST"
# Only 1M+ views
yt-dlp --match-filter "view_count >= 1000000" "CHANNEL"
# Skip live streams
yt-dlp --match-filter "!is_live" "CHANNEL"
# Title contains keyword
yt-dlp --match-filter "title ~= 'tutorial'" "CHANNEL"Metadata & Thumbnails
yt-dlp --embed-metadata "URL" # Embed tags
yt-dlp --embed-thumbnail "URL" # Embed cover art
yt-dlp --write-thumbnail "URL" # Save thumbnail file
yt-dlp --write-description "URL" # Save description
yt-dlp --write-comments "URL" # Save comments (JSON)
yt-dlp --write-info-json "URL" # Save all metadata
# Full music archival combo
yt-dlp -x --audio-format mp3 --embed-metadata --embed-thumbnail "URL"Config Files
Tired of typing the same flags every time? A config file saves your preferred settings so yt-dlp uses them automatically. You create it once, and every future download uses your defaults. Here's exactly how to set it up.
# Run these two commands in Terminal, one at a time:
# 1. Create the config folder
mkdir -p $HOME/.config/yt-dlp
# 2. Open the config file in the nano text editor
# (this creates the file if it doesn't exist)
nano $HOME/.config/yt-dlp/config# Run these in Command Prompt or PowerShell, one at a time:
# 1. Create the config folder
mkdir %APPDATA%\yt-dlp
# 2. Open the config file in Notepad
# (click "Yes" if it asks to create a new file)
notepad %APPDATA%\yt-dlp\config.txt# Copy everything below and paste it into nano / Notepad.
# Remove or add lines to suit your needs.
# Lines starting with # are comments and are ignored.
# Save videos to your Downloads folder
--output ~/Downloads/%(title)s.%(ext)s
# Always output as MP4
--merge-output-format mp4
# Embed metadata (title, artist, date) into the file
--embed-metadata
# Embed the video thumbnail as cover art
--embed-thumbnail
# Download and embed English subtitles
--embed-subs
--sub-langs en
# Skip videos you've already downloaded
--download-archive ~/.config/yt-dlp/archive.txt
# Use 4 connections for faster downloads
--concurrent-fragments 4
# Remove special characters from filenames
--restrict-filenames# macOS/Linux (nano editor):
# 1. Press Ctrl + X (exit)
# 2. Press Y (yes, save changes)
# 3. Press Enter (confirm the filename)
#
# You'll see something like:
# File Name to Write: /Users/you/.config/yt-dlp/config
# Just press Enter β that's the correct path.
#
# Windows (Notepad):
# Just press Ctrl + S to save, then close Notepad.# Just run this β your config defaults apply automatically:
yt-dlp "https://www.youtube.com/watch?v=VIDEO_ID"
# You can still add extra flags on top of your defaults:
yt-dlp -f "bestvideo[height<=720]+bestaudio" "URL"
# Need to ignore your config for one download?
yt-dlp --ignore-config "URL"
# Want to use a completely different config file?
yt-dlp --config-location /path/to/other-config.txt "URL"
# To edit your config later, just run the nano command again:
nano $HOME/.config/yt-dlp/configCommand Builder
Interactive Command Builder
Select your options and get a ready-to-use command.
yt-dlp "URL"
Quick Reference
| Flag | Description | Category |
|---|---|---|
-F | List available formats | Formats |
-f FORMAT | Select format / quality | Formats |
--merge-output-format | Container for merged output | Formats |
--recode-video | Re-encode video to format | Formats |
-x | Extract audio only | Audio |
--audio-format | Audio format (mp3, m4a, opusβ¦) | Audio |
--audio-quality | Audio quality (0=best, or bitrate) | Audio |
-o TEMPLATE | Output filename template | Output |
-P DIR | Download directory path | Output |
--restrict-filenames | Safe characters only | Output |
--write-subs | Download subtitles | Subtitles |
--write-auto-subs | Download auto-generated subs | Subtitles |
--sub-langs LANG | Subtitle language(s) | Subtitles |
--embed-subs | Embed subs in video | Subtitles |
--list-subs | List available subtitles | Subtitles |
-a FILE | Batch file of URLs | Batch |
-I RANGE | Playlist item range | Playlist |
--no-playlist | Single video only | Playlist |
--download-archive | Skip already-downloaded | Playlist |
--dateafter DATE | Videos after date | Filter |
--match-filter | Filter by metadata | Filter |
--embed-metadata | Embed metadata tags | Metadata |
--embed-thumbnail | Embed thumbnail art | Metadata |
--write-thumbnail | Save thumbnail file | Metadata |
--cookies-from-browser | Use browser cookies | Auth |
-N NUM | Concurrent fragments | Network |
-r RATE | Limit download rate | Network |
--proxy URL | Use proxy server | Network |
--download-sections | Download time range | Post-process |
--split-chapters | Split by chapters | Post-process |
-s | Simulate (no download) | Info |
-j | Print JSON metadata | Info |
-U | Update yt-dlp | System |
-v | Verbose output | System |
Troubleshooting
Usually means yt-dlp is outdated.
yt-dlp -U
# If still failing, try cookies:
yt-dlp --cookies-from-browser chrome "URL"The specified format isn't available. Check formats first.
yt-dlp -F "URL" # Check what's available
# Always add /best fallback:
yt-dlp -f "bestvideo[height<=1080]+bestaudio/best" "URL"brew install ffmpeg # macOS
winget install ffmpeg # Windows
sudo apt install ffmpeg # Linux
# Or point to ffmpeg location:
yt-dlp --ffmpeg-location /path/to/ffmpeg "URL"yt-dlp -N 4 "URL" # Concurrent fragments
yt-dlp --cookies-from-browser chrome "URL" # Avoid throttling# Must be logged in to the site in your browser
yt-dlp --cookies-from-browser chrome "URL"yt-dlp supports 1000+ sites. Same commands work everywhere.
yt-dlp "https://vimeo.com/12345678"
yt-dlp "https://x.com/user/status/123456"
yt-dlp --cookies-from-browser chrome "https://instagram.com/p/ABC123"
yt-dlp "https://reddit.com/r/sub/comments/xyz/title"
yt-dlp -x "https://soundcloud.com/artist/track"
# List all supported sites:
yt-dlp --list-extractors