yt-dlp / youtube-dl

youtube-dl is a command-line program for downloading video and audio from YouTube and thousands of other sites. The original ytdl-org/youtube-dl project is effectively unmaintained; the community fork yt-dlp (based on the also-inactive youtube-dlc) is the actively developed successor and what you should install today. It adds multi-threaded fragment downloads, sponsor-block integration, faster extractor fixes, and broader site support, while remaining flag-compatible with youtube-dl in most cases.

Install ffmpeg alongside it — yt-dlp shells out to ffmpeg for muxing separate video+audio streams, format conversion, and metadata embedding.

Common invocations

# Grab an HD MP4 (720p, or the next best LARGER size if 720p
# is unavailable).
yt-dlp \
    --output "%(title)s (%(id)s).%(ext)s" \
    --format "bestvideo[width<=1280][height>540][ext=mp4]+bestaudio[ext=m4a]/bestvideo[width<=1920][height>720][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" \
    --add-metadata "$URL"
 
# Best quality video + audio. Often muxed into an MKV container
# rather than MP4; sometimes you'll get WEBM.
yt-dlp \
    --output "%(title)s (%(id)s).%(ext)s" \
    --format "bestvideo+bestaudio" \
    --add-metadata "$URL"
 
# Best SINGLE-FILE format under 200 MB.
yt-dlp \
    --output "%(title)s (%(id)s).%(ext)s" \
    --format "best[filesize<200M]" \
    --add-metadata "$URL"

The format-selection mini-language (bestvideo[...] + bestaudio[...] / fallback) filters streams by width, height, extension, filesize, codec, and bitrate, with / separating fallbacks tried in order.

Useful resolution specs

NameWidth(Max) HeightNotes
480p854480DVD quality
540p960540”Quarter HD”; uncommon except on VHX
720p1280720Usually just called “HD”
1080p19201080”Full HD”

Keeping it current

Distro repos and even pip lag badly behind the extractor churn (sites change constantly, and YouTube breaks old extractors regularly). Practical options:

  • Grab the standalone binary from the yt-dlp releases page and run yt-dlp -U to self-update.
  • Or run from source in a Python virtual environment:
virtualenv yt-dlp && cd yt-dlp && . bin/activate
git clone https://github.com/yt-dlp/yt-dlp.git
cd yt-dlp && make        # build in place; run as ./yt-dlp, DON'T make install

Notes

  • --add-metadata embeds title/description/upload date into the output file’s tags (requires ffmpeg).
  • -F lists all available formats for a URL without downloading; combine with -f <code>+<code> to pick exact streams.

Sources

See also