yt-dlp Cheat Sheet
The yt-dlp commands I actually use: install and update, format selection, audio, subtitles, playlists, cookies, rate limiting, output templates, and post-processing. ffmpeg is required for merging and audio extraction.
yt-dlp is the free, open-source command-line YouTube downloader I reach for whenever I need video, audio, or subtitles off the command line. It is the maintained community fork of youtube-dl, costs nothing, ships no ads or watermarks, and runs entirely on your own machine. This page is the reference I keep open: every flag worth knowing, grouped by what you are actually trying to do. Build a command first, then scroll for the detail. Below the core reference are the full walkthroughs for downloading a single YouTube video, downloading YouTube audio as M4A, Opus, or MP3, and pulling a YouTube transcript.
Paste a YouTube URL, choose what to grab, and copy the command. It updates as you change the options.
Resolution is a maximum, not a guarantee. yt-dlp grabs the best quality at or below your pick, capped by what was actually uploaded. Choose 8K on a 720p video and you get 720p, not an error and not an upscale.
yt-dlp --merge-output-format mp4 "https://www.youtube.com/watch?v=dQw4w9WgXcQ"Paste this into your terminal AI and it runs the command for you, installing the tool first if you do not have it. Works with Claude Code, OpenAI Codex CLI, Gemini CLI, GitHub Copilot CLI, Aider, Cursor Agent, Warp, OpenCode, Cline and any other CLI coding agent.
Goal: download the video from this YouTube link.
Run this command in my shell:
yt-dlp --merge-output-format mp4 "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
First check whether `yt-dlp` is installed (run `command -v yt-dlp`). If it is not, install it with my system's package manager before running anything: macOS `brew install yt-dlp ffmpeg`, Debian/Ubuntu `sudo apt install yt-dlp ffmpeg`, Fedora `sudo dnf install yt-dlp ffmpeg`, Windows `winget install yt-dlp ffmpeg`. Then run the command above.
Show me any command that needs sudo before you run it, tell me where the output file landed when you are done, and do not run anything else.You run this at your own risk. An AI agent can execute commands on your machine; review what it does before approving. TechEarl is not liable for the outcome, see the Terms of Service.
yt-dlp is a community fork of youtube-dl. Many familiar options carry over, but defaults and compatibility differ; consult the migration notes when adapting an older command.
Download only what you have the right to. Saving your own uploads, Creative Commons material, or content the rights holder permits is one thing; redistributing copyrighted video, or bulk-downloading in a way that violates YouTube's (or any site's) Terms of Service, is another. This reference is for the legitimate cases. What you do with the file is on you.
A note that runs through the whole sheet: install ffmpeg. yt-dlp needs it to merge the separate video and audio streams modern YouTube serves, and to extract or convert audio. The single most common "it only gave me 720p" or "audio extraction failed" complaint is a missing ffmpeg.
The cheat sheet
Everything below is grouped the way I think about a download: get it installed, grab something, then refine quality, audio, subtitles, scale to playlists, and clean up the output.
Install and keep it current
Pick the line for your platform from the install block above. The non-negotiable extra is ffmpeg: Homebrew (brew install yt-dlp ffmpeg) bundles it in one command; on Linux install it with apt/dnf/pacman; on Windows run winget install Gyan.FFmpeg alongside yt-dlp.
Keeping yt-dlp current is not optional with this tool. YouTube changes its player often enough that a stale build simply stops working, and updating is the first thing to try when a download breaks. The standalone binary self-updates with yt-dlp -U; a pipx install updates with pipx upgrade yt-dlp; Homebrew uses brew upgrade yt-dlp. Distro packages (the apt one in particular) lag badly, which is why I prefer pipx for a cross-platform install.
Check dependencies before copying a download command
Run these checks separately:
yt-dlp --version
ffmpeg -version
deno --versionFor full YouTube support, current yt-dlp also needs its JavaScript challenge-solving components and a supported external JavaScript runtime. Deno is the recommended runtime in the official EJS setup guide. Packaging differs: the default Python extras install yt-dlp-ejs, while other distributions may bundle it differently. Follow that guide for your install method.
First inspect formats with yt-dlp -F "URL", then choose one download command. Do not paste the whole cheat sheet as a script: the entries are alternatives. Rate limits, unavailable media, and account restrictions can still prevent a download.
Picking the quality
Run yt-dlp -F "URL" to see what a video actually offers: a table of format IDs, resolutions, codecs, and sizes. Then select with -f. The selector I use almost always is bv*[height<=1080]+ba/b[height<=1080], which reads as "best video at or below 1080p, plus best audio, or fall back to the best single file." Change 1080 to whatever ceiling you want; the [height<=N] filter is a ceiling, not a request, so you only get 4K if the creator uploaded 4K.
The trap to avoid is -f best. On modern YouTube the high resolutions are served as separate video-only and audio-only streams, and best only matches a single already-combined (muxed) file, which YouTube caps at around 720p. So -f best quietly hands you 720p and people conclude yt-dlp "can't do 1080p." The bv*+ba selector plus ffmpeg is the fix. For the full walkthrough, including Shorts and the bot check, see downloading a YouTube video in any quality below.
Audio only
For an MP3 file, install ffmpeg and run:
yt-dlp -x --audio-format mp3 --audio-quality 0 "URL"This converts the selected audio to MP3. A higher output bitrate does not restore detail missing from the source. For an available native M4A track without an Opus-to-AAC conversion, select that format explicitly:
yt-dlp -f "ba[ext=m4a]" -x --audio-format m4a "URL"That command fails if no matching M4A source is available, rather than silently transcoding a different codec. Use yt-dlp -F "URL" to inspect formats first. Add --embed-thumbnail --embed-metadata if you want supported artwork and tags. See MP3, M4A, and Opus audio downloads below for the full walkthrough.
Subtitles and transcripts
yt-dlp --list-subs "URL" shows which languages a video has, including auto-generated captions. To pull the text without the video, combine --skip-download with --write-subs --write-auto-subs --sub-langs en --convert-subs srt. That writes an SRT file (or VTT if you skip the conversion) and nothing else, which is exactly what you want when feeding a summarizer or taking notes. For converting captions to clean plain text, and the Whisper fallback when a video has none, see download a YouTube transcript below.
Playlists, channels, and archives
Point yt-dlp at a playlist URL or a channel @handle URL and it downloads the lot. Two flags make bulk jobs sane. --download-archive archive.txt records every video ID it finishes, so re-running the same command skips what you already have, which turns a one-shot grab into something you can run weekly. --playlist-items 1-10 (or a comma list) limits the range. An output template like -o "%(playlist_index)s - %(title)s.%(ext)s" numbers the files so they sort in playlist order. The full resumable channel workflow, with rate limiting, is in download a YouTube playlist or channel.
Cookies, auth, and the Chrome gotcha
When YouTube interrupts a download with "Sign in to confirm you're not a bot," or when a video is members-only, age-restricted, or region-locked and you have legitimate access, hand yt-dlp your browser cookies:
yt-dlp --cookies-from-browser firefox "URL"Cookie support depends on the browser, OS, profile permissions, and encryption. Chromium app-bound encryption on Windows can prevent extraction; this is not a universal ban on Chrome across every platform. Consult the yt-dlp cookie FAQ. Cookies are account credentials: keep exports private and never include them in shared logs.
Being polite to the server
For anything beyond a single video, throttle yourself. --sleep-requests 1 puts a second between requests; -r 3M (or its long form --limit-rate 3M) caps the download rate. This is partly courtesy and partly self-preservation: hammering a site is the fastest way to trip its bot detection and get your IP rate-limited. The same etiquette applies to every extractor, including TikTok video downloads and Facebook video downloads.
Output templates
By default yt-dlp bakes the video ID into the filename. An output template (-o) fixes that. -o "%(title)s.%(ext)s" gives a readable name; -o "%(uploader)s/%(upload_date)s - %(title)s.%(ext)s" builds a per-uploader folder tree dated by upload. There are dozens of fields (uploader, resolution, id, playlist_index); the percent-paren-s syntax is the standard output-template form documented in the yt-dlp README.
Post-processing
The post-processors run after the download finishes. --embed-subs (with --write-subs) and --embed-chapters fold subtitles and chapter markers into the file. --remux-video mp4 repackages into MP4 without re-encoding when the codecs are already compatible, which is fast and lossless. --sponsorblock-mark all uses the community SponsorBlock database to mark sponsor, intro, and outro segments as chapters; swap mark for remove to physically cut them out. These compose with everything above, so a single command can download at 1080p, embed subtitles, and strip sponsor segments in one pass.
Download a YouTube video
For a single video the default is the whole job: yt-dlp "URL" picks the best video and best audio streams, downloads both, and merges them into one file. Set the builder at the top of the page to Video, paste the URL, and copy the command. The rest of this section is the detail behind it: installing for your OS, choosing a resolution, saving a Short, and getting past the bot check.
If you came here searching for youtube-dl, yt-dlp is its actively maintained successor. youtube-dl still exists but routinely breaks when YouTube changes its player; yt-dlp keeps up, with a faster release cadence and far more extractors.
Install for your OS
Pick your platform. Install ffmpeg in the same step, since the merge and any audio conversion depend on it.
Pick your OS for the install command.
# Cross-platform and always current:
pipx install "yt-dlp[default]"
sudo apt install ffmpeg # or your distro's package managerYou do not pick an Apple Silicon vs Intel build by hand. Homebrew, pipx, and winget all install the right binary for your machine (the same brew install yt-dlp ffmpeg works on an M-series and an Intel Mac), and yt-dlp itself is Python, so it is architecture-independent. The chip only matters if you download the raw standalone binary manually.
Choose a resolution
List what the video actually offers, then cap the height with a format selector:
yt-dlp -F "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
# 1080p or below, plus the best audio, merged
yt-dlp -f "bv*[height<=1080]+ba/b[height<=1080]" "https://www.youtube.com/watch?v=dQw4w9WgXcQ"The resolution is a ceiling, not a request for a specific size. The [height<=N] filter means "the best stream at or below N," and it has to sit on both sides of the /: the fallback after the slash is a separate selector, so a bare /b would happily grab a combined file above your ceiling. You only get 4K or 8K if the creator uploaded at that resolution; ask for 8K on a video that tops out at 720p and yt-dlp downloads the 720p version. It does not error, and it never upscales a low-resolution source. If the result is stuck at 720p regardless of what you ask for, you are hitting the -f best trap described under picking the quality.
Download a YouTube Short
A Short is a regular video on a /shorts/ URL, so the same command works:
yt-dlp "https://www.youtube.com/shorts/VIDEO_ID"There is no special flag for Shorts. If you ever get a playlist instead of the single clip (some Shorts URLs resolve to a feed), force a single video with --no-playlist.
Fix "Sign in to confirm you're not a bot"
YouTube increasingly interrupts downloads with Sign in to confirm you're not a bot. Update yt-dlp first (yt-dlp -U, pipx upgrade yt-dlp, or brew upgrade yt-dlp), since a stale build causes a lot of sudden failures. If the message persists, pass your browser session so the request looks like your logged-in browser:
yt-dlp --cookies-from-browser firefox "https://www.youtube.com/watch?v=dQw4w9WgXcQ"Firefox is the safer choice; the platform caveats for Chrome are in the cookies section above. The same cookies are what unlock members-only, age-restricted, and region-locked videos you have legitimate access to.
Download YouTube audio
To download only the audio from a YouTube video, set the builder at the top of the page to Audio, or run -x (short for --extract-audio) with a format selector that asks for the stream YouTube already serves:
# M4A/AAC: copied as-is when an M4A stream exists, converted only as a fallback
yt-dlp -f "bestaudio[ext=m4a]/bestaudio" -x --audio-format m4a "URL"The one decision that matters is the format. YouTube serves two native audio streams: AAC in an M4A container and Opus inside WebM. Ask for the one that matches what you want and yt-dlp can keep the original audio with no re-encode. MP3 is here too, because "youtube to mp3" is what a lot of people search for, but YouTube does not serve MP3, so it always means a lossy conversion.
Download only audio you have the right to. Your own uploads, Creative Commons tracks, podcasts, or material the rights holder permits are fine; ripping copyrighted music to redistribute is not.
Why the format selector matters
--audio-format only sets the conversion target; it does not choose which stream gets downloaded. Left to itself, bestaudio usually picks YouTube's Opus stream, and then ffmpeg has to convert Opus to AAC to satisfy m4a. The -f "bestaudio[ext=m4a]/bestaudio" selector asks for the M4A stream first, so yt-dlp keeps it as delivered, and only falls back to whatever audio exists if a video has no M4A track. When the downloaded file is already in the target format, yt-dlp logs "Not converting audio ... already is in target format".
The two selectors on this page trade off differently. The strict -f "ba[ext=m4a]" form under audio only fails when no M4A source exists, so you never get a silent transcode. The bestaudio[ext=m4a]/bestaudio form always produces a file, converting only when it has to. Run yt-dlp -F "URL" first if you want to see which audio formats a video offers.
Add cover art and tags
For a music library, embed the thumbnail as cover art and fill the title, artist, and date tags from YouTube's metadata:
yt-dlp -f "bestaudio[ext=m4a]/bestaudio" -x --audio-format m4a --embed-thumbnail --embed-metadata "URL"Tags will not even out wildly different playback levels between tracks from different sources. For that, normalize the audio volume with ffmpeg's loudnorm filter.
Convert YouTube to Opus
Opus gives the smallest file at a given quality, and modern phones, browsers, and most desktop players handle it. Because YouTube already ships Opus inside WebM, the no-loss route is to grab that stream and remux it into an Opus container instead of converting it:
# Native Opus stream copied into an .opus container (no re-encode)
yt-dlp -f "bestaudio[ext=webm]/bestaudio" --remux-video opus "URL"
# Also produces an .opus file, but --audio-format is a conversion step
yt-dlp -f "bestaudio[ext=webm]/bestaudio" -x --audio-format opus "URL"Remuxing changes the container, not the audio. --audio-format runs ffmpeg's audio-conversion postprocessor, which can re-encode rather than copy, so I keep it for the case where a video has no Opus stream (some older or audio-restricted uploads ship only AAC) and a transcode is genuinely wanted. Add --embed-thumbnail --embed-metadata to either command for cover art and tags.
Convert YouTube to MP3 (only when a device needs it)
yt-dlp -x --audio-format mp3 --audio-quality 0 "URL"YouTube's source audio is already lossy AAC or Opus. Converting to MP3 decodes it and re-encodes with a different lossy codec, stacking a second generation of loss on the first. At --audio-quality 0 the drop is small, but it is never an improvement, and the MP3 is typically larger than the Opus file at comparable quality. Reserve it for an old car stereo, a basic MP3 player, or another device that cannot play M4A or Opus.
A whole playlist, or a long mix split by chapter
The same command walks every entry of a playlist URL. For a long DJ set, podcast, or compilation with YouTube chapters, --split-chapters writes one file per chapter:
# A whole playlist to audio
yt-dlp -f "bestaudio[ext=m4a]/bestaudio" -x --audio-format m4a "PLAYLIST_URL"
# One long video split into one file per chapter
yt-dlp -f "bestaudio[ext=m4a]/bestaudio" -x --audio-format m4a --split-chapters "URL"Add --download-archive archive.txt so re-runs skip what you already have; the full bulk workflow is in download a YouTube playlist or channel.
Download a YouTube transcript
To get a YouTube video's transcript without the video, run yt-dlp with --skip-download plus the subtitle flags, then strip the timestamps with one sed line. That leaves plain prose you can paste into notes or an AI summarizer. Set the builder at the top of the page to Transcript for a ready-made command, or work through the steps below.
Reading a transcript for your own notes or feeding it to a summarizer is one thing; republishing someone else's captions as your own content is another, and bulk scraping can violate YouTube's Terms of Service.
Uploaded vs auto-generated captions
YouTube has two distinct caption tracks, and yt-dlp uses a different flag for each:
- Creator-uploaded captions (
--write-subs). The owner uploaded or hand-corrected these. They are accurate and properly punctuated, but many videos do not have them. - Auto-generated captions (
--write-auto-subs). YouTube's own speech-to-text. Almost every video with spoken English has them, so they are the reliable fallback, but they have little punctuation and they mangle names, jargon, and homophones. Good enough to feed a summarizer; not good enough to publish verbatim.
Ask for both and yt-dlp grabs whichever is present: uploaded wins when available, auto fills the gap.
List the caption tracks
yt-dlp --list-subs "https://www.youtube.com/watch?v=dQw4w9WgXcQ"That prints two tables: the available subtitles (creator-uploaded) and the available automatic captions, each with a language code (en, en-US, es, and so on) and the formats on offer (vtt, srt, ttml). If the subtitles table is empty but the automatic-captions table lists en, you are relying on --write-auto-subs. If both are empty, there are no captions at all and you skip to the Whisper fallback below.
Download the transcript only, no video
# Uploaded + auto captions, English, written out as SRT, no video
yt-dlp --skip-download --write-subs --write-auto-subs --sub-langs en --convert-subs srt "https://www.youtube.com/watch?v=dQw4w9WgXcQ"--skip-downloadskips the video entirely; you only get the caption file.--write-subsrequests creator-uploaded captions;--write-auto-subsrequests the auto ones as a fallback.--sub-langs enlimits it to English. Useen.*to catchen-US/en-GBvariants, or a comma list likeen,esfor several languages.--convert-subs srtnormalizes whatever YouTube serves into SubRip (.srt). Swap invttfor WebVTT.
You get a file named something like Video Title [VIDEO_ID].en.srt. SRT and VTT carry the same words and differ only in the timecode syntax and a header line: pick SRT if a downstream tool expects it, VTT if you are embedding in HTML5 video. For a summarizer, neither matters once the timing is stripped.
Convert SRT or VTT to plain text
yt-dlp converts between subtitle formats, but it does not output a plain .txt. An SRT file is interleaved with sequence numbers, 00:00:01,200 --> 00:00:03,800 timestamp lines, and blank separators. One sed removes all three:
# Strip indices, timestamp lines, and blanks down to plain prose
sed -E '/^[0-9]+$/d; /-->/d; /^$/d' "Video Title [VIDEO_ID].en.srt" > transcript.txtThe result is one line per caption cue, which most summarizers handle fine; pipe it through fmt if you want paragraphs. The same sed works on a .vtt file, since VTT timestamp lines also contain -->, though you may want to drop the leading WEBVTT header line it leaves behind.
To download and clean in one command, keep the filename predictable with an %(id)s output template so the glob is easy:
# Download the auto/uploaded EN captions, then immediately flatten to text
yt-dlp --skip-download --write-subs --write-auto-subs --sub-langs en --convert-subs srt -o "%(id)s.%(ext)s" "URL" \
&& sed -E '/^[0-9]+$/d; /-->/d; /^$/d' *.en.srt > transcript.txtNo captions? Transcribe with Whisper
Some videos have neither uploaded nor auto captions: music, very new uploads, languages YouTube does not auto-caption well. When --list-subs comes back empty, download the audio and transcribe it locally with OpenAI Whisper, a free, open-source speech-to-text model that runs on your own machine with no API key:
# Grab the audio, then transcribe it to a .txt locally
yt-dlp -x --audio-format m4a -o audio.m4a "URL" && whisper audio.m4a --model small --output_format txt--output_format txt writes a clean audio.txt with no timestamps, so there is no sed step. --model small is a good speed/accuracy balance on a laptop; tiny/base are faster, medium/large are more accurate but want a GPU. Install it with pip install -U openai-whisper (it needs ffmpeg, which you already have for yt-dlp). On a machine with no GPU, whisper.cpp, the same model reimplemented in C++, is noticeably faster and also free.
FAQ
Yes. yt-dlp is free and open source (released into the public domain under the Unlicense), with no ads, no paywall, no watermark, and no download limits. Unlike the "free YouTube downloader" websites that wrap a tool like this in ads and trackers, yt-dlp runs entirely on your own machine and costs nothing.
yt-dlp. It is the maintained fork of youtube-dl (originally written by Ricardo García, "rg3"), ships far more frequently, has many more extractors, and keeps working when YouTube changes its player. youtube-dl is no longer actively maintained and breaks often. Many options are compatible, but check the documented differences before reusing an old command.
For best results, yes. The high-resolution video and audio arrive as separate streams and ffmpeg merges them into one file. Audio extraction (-x) and format conversion will not work at all without it. Install it alongside yt-dlp: brew install yt-dlp ffmpeg on macOS, winget install Gyan.FFmpeg on Windows, or your distro's package on Linux.
Cookie extraction depends on platform encryption, browser version, and profile access. Windows Chromium app-bound encryption can prevent it. A supported Firefox profile is one alternative; see the official cookie FAQ and keep any cookie export private.
You are almost certainly using -f best, which only matches a single combined stream, and YouTube caps those at ~720p. Use a bestvideo+bestaudio selector such as -f "bv*[height<=1080]+ba/b[height<=1080]" and make sure ffmpeg is installed so yt-dlp can merge the higher-resolution video and audio into one file.
Update yt-dlp first (yt-dlp -U or pipx upgrade yt-dlp), which resolves a lot of sudden failures. If it persists, pass your browser session with yt-dlp --cookies-from-browser firefox URL. Firefox avoids the Chromium cookie-encryption problems described above.
M4A. YouTube serves AAC audio in an M4A container, so selecting that stream with -f "bestaudio[ext=m4a]/bestaudio" and extracting to m4a keeps the original audio. Plain --audio-format m4a can still convert, because the default bestaudio often picks the Opus stream. MP3 always means a second lossy conversion, so choose it only when a specific old device demands it.
Run yt-dlp -x --audio-format mp3 --audio-quality 0 "URL" with ffmpeg installed. YouTube does not serve MP3, so this re-encodes from a lossy source and loses a little quality. Extract to m4a or opus instead unless a device cannot play those.
You left out --skip-download. Without it, yt-dlp downloads the video and the captions. Add it and yt-dlp fetches only the subtitle file, which is what makes transcript extraction fast and bandwidth-cheap.
Yes. Run yt-dlp --list-subs URL to see which language codes the video offers, then set --sub-langs to that code (for example --sub-langs es for Spanish, or --sub-langs en,es for both). A pattern like en.* catches regional variants such as en-US and en-GB in one go.
Yes, by transcribing the audio yourself. Extract it with yt-dlp -x, then run OpenAI Whisper: whisper audio.m4a --model small --output_format txt. Whisper is free, open source, runs locally with no API key, and writes a clean text file directly. On a machine with no GPU, whisper.cpp does the same job much faster.
Yes. yt-dlp ships thousands of extractors. The same tool and most of these flags work on TikTok, Instagram, Facebook, and many more. See download a TikTok video, download an Instagram Reel, and download a Facebook video for the per-site notes (mainly which cookies each one needs).
See also
- Download a YouTube playlist or channel: the bulk workflow with
--download-archiveand output templates. - Download a TikTok video: the same tool, with TikTok's cookie note.
- Download a TikTok profile: grab every video from one account with an archive file.
- Download an Instagram Reel: pull a Reel (and what Instagram needs for cookies).
- Download a Facebook video: save a public Facebook video from the command line.
Sources
Authoritative references this article was fact-checked against.
- yt-dlp README: filtering formatsgithub.com
- yt-dlp README (official)github.com
- yt-dlp format selection (official docs)github.com
- yt-dlp output template (official docs)github.com
- yt-dlp FAQ (official wiki)github.com
- yt-dlp FAQ: passing cookies (official wiki)github.com
- yt-dlp subtitle options (official docs)github.com
- OpenAI Whisper README (official)github.com
- whisper.cpp (official repository)github.com
- yt-dlp post-processing options (official docs)github.com
- yt-dlp audio extraction and format (official docs)github.com




![Set the Date and Time From the macOS Command Line (BSD date) Set the macOS clock from Terminal with the BSD date command: MMDDhhmm[[CC]YY], not date -I (an ISO 8601 output flag that sets nothing). Turn off network time first or macOS resyncs.](https://images.techearl.com/mac-set-date-command-line/mac-set-date-command-line-1536.webp?v=2026-11-25T10%3A00%3A00-05%3A00)
