DEV Community

Dhiraj Chaurasiya
Dhiraj Chaurasiya

Posted on • Edited on

yt-dlp for youtube video downloads.

How to Use yt-dlp: The Ultimate Guide to Downloading Videos from YouTube and More

If you’ve ever wanted to download videos or playlists from YouTube or many other streaming platforms, yt-dlp is one of the best tools you can use. It’s a powerful command-line program that lets you grab videos, audios, subtitles, and more — all with simple commands.

In this article, I’ll walk you through:

  • What yt-dlp is
  • How to install it
  • Basic and advanced commands
  • How to download videos at specific quality (like 720p)
  • Downloading entire playlists
  • Tips and tricks for better downloads

What is yt-dlp?

yt-dlp is a fork of the popular tool youtube-dl. It’s actively maintained, with new features, bug fixes, and supports many more sites. It’s perfect for anyone who wants control over downloading videos with great quality and options.


Installing yt-dlp

You can install yt-dlp easily:

  • Windows:

    Download the executable from the yt-dlp GitHub releases and put it in a folder in your PATH.

  • macOS:

  brew install yt-dlp
Enter fullscreen mode Exit fullscreen mode
  • Linux: Most distros have yt-dlp in their package managers, or you can use pip:
  python3 -m pip install -U yt-dlp
Enter fullscreen mode Exit fullscreen mode

Basic Command to Download a Video

To download a video, simply run:

yt-dlp <video_url>
Enter fullscreen mode Exit fullscreen mode

Note: Replace the <video_url> with actual url of video.
eg: yt-dlp https://youtu.be/bZ2o8ideUYY?si=it5cVDmJljdBA8h4

This downloads the best available quality by default.


Download a Video in 720p Quality

To download a video in 720p, use the format selector:

yt-dlp -f "bestvideo[height<=720]+bestaudio/best[height<=720]" <video_url>
Enter fullscreen mode Exit fullscreen mode

What does this mean?

  • -f means format selection.
  • bestvideo[height<=720] chooses the best video-only stream up to 720p.
  • bestaudio grabs the best audio-only stream.
  • The + tells yt-dlp to merge video and audio.
  • The fallback best[height<=720] downloads the best combined stream up to 720p if separate streams are not available.

Note: You need ffmpeg installed to merge video and audio streams. Without ffmpeg, yt-dlp will download video and audio separately but won’t merge them.

The guide to install ffmpeg is discussed in tips below.

Extra

To download a playlist in 720p sorted in same order.

yt-dlp -f "bestvideo[height<=720]+bestaudio/best[height<=720]" -o "%(playlist_index)03d. %(title)s.%(ext)s" https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID
Enter fullscreen mode Exit fullscreen mode

Additional Useful Commands

Download audio only:

yt-dlp -f bestaudio <video_url>
Enter fullscreen mode Exit fullscreen mode

Download subtitles if available:

yt-dlp --write-subs --sub-lang en <video_url>
Enter fullscreen mode Exit fullscreen mode

List available formats:

yt-dlp -F <video_url>
Enter fullscreen mode Exit fullscreen mode

Tips for Better Downloads

  • Always keep yt-dlp updated for latest site support:
  yt-dlp -U
Enter fullscreen mode Exit fullscreen mode

Conclusion

yt-dlp is a versatile tool that can make downloading videos easy and customizable. Whether you want a single video in 720p or a whole playlist, yt-dlp has you covered.

Top comments (0)