TechEarl

yt-dlp Cheat Sheet: Download Video, Audio, and Subtitles From the Command Line

A scannable yt-dlp reference: install and update, format selection, audio extraction, subtitles, playlists and channels, cookies and auth, rate limiting, output templates, and post-processing. The free, maintained youtube-dl successor.

Ishan Karunaratne⏱️ 6 min readUpdated
Share thisCopied
yt-dlp cheat sheet: install and update, list and select formats, extract audio to M4A, write subtitles, download playlists and channels with an archive file, pass browser cookies, rate-limit politely, and post-process with SponsorBlock. The free youtube-dl successor.

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.

Install & update

brew install yt-dlp ffmpegmacOS (Homebrew). Installs ffmpeg too, which yt-dlp needs to merge streams and extract audio.
pipx install "yt-dlp[default]"Install with the default Python extras. Install ffmpeg and a supported JavaScript runtime separately when needed.
winget install yt-dlp.yt-dlpWindows. Also run winget install Gyan.FFmpeg for ffmpeg.
yt-dlp -USelf-update the standalone binary in place. First thing to try when a download suddenly fails.
pipx upgrade yt-dlpUpdate a pipx install. With Homebrew use brew upgrade yt-dlp.

Basic download

yt-dlp "URL"Best video + best audio, downloaded separately and merged into one file. The default does the whole job for most people.
yt-dlp -a urls.txtBatch download from a text file, one URL per line. Blank lines and # comments are ignored.
yt-dlp --no-playlist "URL"Download just the single video when a URL also carries a playlist (the &list= case).

Format selection

yt-dlp -F "URL"List every available format with its ID, resolution, codec, and size. Run this first when in doubt.
yt-dlp -f "bv*[height<=1080]+ba/b[height<=1080]" "URL"Best video up to 1080p plus best audio, merged; fall back to the best single file if that fails.
avoid -f bestIt only matches a single muxed file, which YouTube caps at ~720p. Use the bv*+ba selector instead.
--merge-output-format mp4Force the merged container to MP4 instead of whatever yt-dlp picks (often MKV/WebM).

Audio

yt-dlp -x --audio-format m4a --audio-quality 0 "URL"Extract to M4A. This may transcode if the selected source is not AAC; select an available M4A source to avoid that conversion.
--audio-format opusExtract to Opus, YouTube's other native audio codec. Small and high quality.
--audio-format mp3Legacy MP3 for old players. This re-encodes, so it loses a little quality. Avoid unless you need MP3.
--embed-thumbnail --embed-metadataEmbed the cover art and the title/artist/date tags into the audio file.
--split-chaptersSplit a long video into one file per chapter using the video's chapter markers.

Subtitles / transcript

yt-dlp --list-subs "URL"List the subtitle and auto-caption languages available for a video.
yt-dlp --skip-download --write-subs --write-auto-subs --sub-langs en --convert-subs srt "URL"Grab English subtitles (manual and auto), convert to SRT, and download no video.

Playlists & channels

yt-dlp "PLAYLIST_URL"Download every video in a playlist. Point it at a playlist URL and let it run.
yt-dlp "https://www.youtube.com/@handle"Download a channel's videos by its @handle URL.
--download-archive archive.txtRecord each downloaded ID so re-runs skip what you already have. Essential for resumable channel grabs.
--playlist-items 1-10Limit to a range (or a comma list like 1,3,5-8) instead of the whole playlist.
-o "%(playlist_index)s - %(title)s.%(ext)s"Number files by their position in the playlist so they sort in order.

Cookies & auth

--cookies-from-browser firefoxUse a Firefox session for content your account can access. Cookie extraction depends on the browser and OS; protect session data.
--cookies cookies.txtPass a Netscape-format cookies file exported from a browser extension.

Politeness / rate limit

-r 3MCap the download rate at 3 MB/s (alias for --limit-rate).
--sleep-requests 1Sleep 1 second between requests. Eases off on bulk jobs so you do not trip the bot wall.
--limit-rate 2MThrottle to 2 MB/s. The long form of -r.

Output templates

-o "%(title)s.%(ext)s"Readable filename from the video title and extension instead of the raw video ID.
-o "%(uploader)s/%(upload_date)s - %(title)s.%(ext)s"Sort into per-uploader folders, prefixed with the upload date.

Post-processing

--embed-subsEmbed subtitles into the video file (pair with --write-subs to fetch them).
--embed-chaptersWrite the video's chapter markers into the file so players show them.
--sponsorblock-mark allMark sponsor/intro/outro segments as chapters using the SponsorBlock database. Use --sponsorblock-remove to cut them out.
--remux-video mp4Remux into MP4 without re-encoding when the streams are already compatible. Fast and lossless.

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.

Build your yt-dlp command

Paste a YouTube URL, choose what to grab, and copy the command. It updates as you change the options.

Profile / bulk 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.

Your command
bash
yt-dlp --merge-output-format mp4 "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
AI CLI prompt

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.

prompt
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:

bash
yt-dlp --version
ffmpeg -version
deno --version

For 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 how to download a YouTube video in any quality.

Audio only

For an MP3 file, install ffmpeg and run:

bash
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:

bash
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 for more options.

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, see extract a YouTube video's transcript or captions.

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:

bash
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.

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.

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

Sources

Authoritative references this article was fact-checked against.

Tagsyt-dlpyoutube-dlYouTubefree youtube downloaderCLIffmpegyoutube downloader command line

Found this useful? Pass it on.

Copied

Ishan Karunaratne

Systems and Network Architect · Chief Technology Officer

Systems and network architect and Chief Technology Officer with more than two decades designing, building, and running production software, cloud and network architecture, Linux systems, and the bare metal underneath them, and lately working AI into the stack. A US Army veteran who served in Operation Iraqi Freedom. What I write here is drawn from the full arc of that work, across architecture, engineering, and operations, not any single job.

Keep reading

Related posts

Normalize MP3 and audio volume from the command line with ffmpeg loudnorm (EBU R128 LUFS) and rsgain ReplayGain tagging across a library.

How to Normalize Audio Volume From the Command Line

Normalize MP3 and audio volume from the command line: ffmpeg's loudnorm filter for EBU R128 loudness (one-pass and the accurate two-pass), rsgain for ReplayGain tags across a whole library, and why loudness beats peak normalization.