Browse documentation
Guides
Copy a recipe for video, audio, captions, datasets or collection recovery.
On this page
Setup and command conventions
python -m pip install -U --pre "yt-dlp[default,curl-cffi]"
deno --version
ffmpeg -version
python -m yt_dlp --list-impersonate-targetsThe download recipes use Deno and --impersonate="" as the baseline. The latter requires curl-cffi and lets it choose an available browser fingerprint. Linux/macOS commands use Bash syntax; for a scheduled worker, also make these dependencies available in that service environment.
These terminal examples use the Python installation of yt-dlp. Use your virtual-environment Python, or replace python -m yt_dlp with the standalone yt-dlp command. Use Linux first, with macOS and Windows alternatives in the setup guide. Install FFmpeg/ffprobe for merging and Deno for YouTube challenge solving. Replace the example URL with your source.
| Convention | Why it matters |
|---|---|
| Quote URLs and templates | The shell otherwise interprets characters such as &, spaces and parentheses. |
| Keep %(ext)s in filenames | The selected media and post-processing determine the extension. |
| Use --no-playlist for a watch URL | A video linked from a playlist should not unexpectedly expand your job. |
| Check your saved configuration | Examples may inherit a global config. Use --ignore-config for an isolated test. |
| Windows .bat: double template percent signs | Use %%(id)s in a batch file, but %(id)s in interactive PowerShell and normal config files. |
Video quality and MP4
Baseline: latest nightly, Deno and FFmpeg, with --impersonate="". The recipes use Bash; replace the sample URL with your source.
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -P downloads \
-o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
-F "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -S "res:1080" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
-f "bv*[height<=1080]+ba/b[height<=1080]" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
-f "bv[vcodec^=avc1][height<=1080]+ba[acodec^=mp4a]/b[vcodec^=avc1][acodec^=mp4a][height<=1080]" \
--merge-output-format mp4 "https://www.youtube.com/watch?v=jNQXAC9IVRw"AI dataset: MP4 + captions + metadata
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
-f "bestvideo+bestaudio/best" --merge-output-format mp4 --remux-video mp4 \
--write-info-json --write-subs --write-auto-subs --sub-langs "en" --sub-format "vtt/best" \
--sleep-subtitles 5 --concurrent-fragments 1 -P dataset -o "%(id)s/%(id)s.%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"External downloader: aria2c
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist --downloader aria2c \
--downloader "dash,m3u8:native" --downloader-args "aria2c:-x 2 -s 2 -j 1" \
--concurrent-fragments 1 -P downloads "https://www.youtube.com/watch?v=jNQXAC9IVRw"aria2 has its own network implementation. yt-dlp's curl-cffi impersonation does not configure aria2's fingerprint. If only the external downloader fails, use --downloader native and compare the same source and proxy route.
Audio and MP3
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -f ba -P audio \
-o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -f ba -x \
--audio-format mp3 --audio-quality 192K -P audio \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -f "ba[ext=m4a]" -P audio \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist -f ba -x \
--audio-format mp3 --embed-metadata --embed-thumbnail -P audio \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"Captions and subtitles
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--list-subs "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-subs \
--sub-langs "en.*" --sub-format "vtt/best" -P captions -o "%(id)s.%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-subs \
--write-auto-subs --sub-langs "en.*" --sub-format "vtt/best" -P captions \
-o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-subs \
--write-auto-subs --sub-langs "en" --convert-subs srt -P captions \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --write-subs --sub-langs "en" \
--embed-subs --remux-video mkv -P downloads "https://www.youtube.com/watch?v=jNQXAC9IVRw"Requesting all caption languages can greatly increase the number of requests and files. Keep the requested languages explicit for routine work. Preserve the source ID and language in your dataset inventory so transcripts do not get detached from the media they describe.
Metadata and output paths
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--dump-json "https://www.youtube.com/watch?v=jNQXAC9IVRw" > video.jsonpython -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-info-json \
-P metadata -o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --skip-download --write-thumbnail \
-P thumbnails -o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--print after_move:filepath -P downloads -o "%(id)s.%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--print-to-file after_move:filepath completed-paths.txt -P downloads \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"Time ranges and chapters
python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--download-sections "*00:00:05-00:00:10" -o "clips/%(id)s-%(section_start)s.%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --no-playlist \
--download-sections "*00:00:05-00:00:10" --force-keyframes-at-cuts \
-o "clips/%(id)s-%(section_start)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --split-chapters -o "chapter:%(id)s-%(section_number)03d.%(ext)s" \
"https://www.youtube.com/watch?v=YOUR_VIDEO_ID"Use a different output policy or archive for clips and full videos. A source-level archive entry does not encode the selected start/end times, so one shared archive can suppress a later clip you intended to create.
Playlists and URL lists
python -m yt_dlp --no-playlist --batch-file urls.txt -P collection -o "%(id)s.%(ext)s"python -m yt_dlp --flat-playlist \
--dump-json "https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID" > playlist.jsonlpython -m yt_dlp --playlist-items 1:5 -P collection -o "%(playlist_index)03d-%(id)s.%(ext)s" \
"https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID"python -m yt_dlp --dateafter 20260101 --match-filters "!is_live & duration <= 1800" \
--batch-file urls.txtpython -m yt_dlp --download-archive archive.txt --max-downloads 10 --batch-file urls.txtArchives and recovery
python -m yt_dlp --download-archive archive.txt --continue --no-abort-on-error -P collection \
-o "%(id)s.%(ext)s" --batch-file urls.txtpython -m yt_dlp --sleep-requests 1 --sleep-interval 5 --max-sleep-interval 10 --retries 3 \
--fragment-retries 3 --socket-timeout 30 --batch-file urls.txtpython -m yt_dlp --js-runtimes deno --impersonate="" --limit-rate 2M \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --concurrent-fragments 1 \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"Configuration and filenames
python -m yt_dlp --ignore-config --config-locations yt-dlp-work.conf --batch-file urls.txtpython -m yt_dlp --js-runtimes deno --impersonate="" -P downloads \
-o "%(channel_id)s/%(upload_date)s-%(title).150B [%(id)s].%(ext)s" \
"https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" -P "home:downloads" -P "temp:work" \
-o "%(id)s.%(ext)s" "https://www.youtube.com/watch?v=jNQXAC9IVRw"For long-lived collections, decide whether filenames should be human-readable or stable application keys. Channel names and titles can change. Channel/video IDs are better keys for deduplication, with descriptive fields kept in metadata.
Cookies and runtime paths
python -m yt_dlp --js-runtimes deno --impersonate="" \
--cookies-from-browser "chrome:Profile 1" \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --cookies private/youtube-cookies.txt \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes "deno:/opt/deno/bin/deno" --impersonate="" \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw"Diagnostics and verification
python -m yt_dlp --js-runtimes deno --impersonate="" --ignore-config --verbose --simulate \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw"python -m yt_dlp --js-runtimes deno --impersonate="" --ignore-config --verbose --simulate \
--no-playlist "https://www.youtube.com/watch?v=jNQXAC9IVRw" > diagnostic.log 2>&1ffprobe -v error -show_entries format=duration,size:stream=codec_type,codec_name,width,height -of json "YOUR_OUTPUT_FILE"ffmpeg -v error -i "YOUR_OUTPUT_FILE" -f null -python -m pip install -U --pre "yt-dlp[default,curl-cffi]"
python -m yt_dlp --version