Download YouTube Videos Using yt-dlp

The best tool to download anything from YouTube or any other video content/streaming platform is yt-dlp.

Here is a handful of commands to get you started.

It’s a good idea to update yt-dlp to stay ahead of the video platforms’ blocking tactics:
yt-dlp -U

If the above command doesn’t help, you can switch to the most current nightly build:
yt-dlp -U --update-to nightly

To download the best available MP4 version of a YouTube video, use:
yt-dlp -f mp4 https://www.youtube.com/watch?v=jNQXAC9IVRw

To only download the MP3 audio from a YouTube video, use:
yt-dlp -x --audio-format mp3 --audio-quality 192k https://www.youtube.com/watch?v=jNQXAC9IVRw

Obviously, you can change the flags to get different formats or audio quality.

If there is an entire playlist you want to download, use:
yt-dlp -o "%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s" -f mp4 https://www.youtube.com/playlist?list=PLCD0445C57F2B7F41

or

yt-dlp -o "%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s" -x --audio-format mp3 --audio-quality 320k https://www.youtube.com/playlist?list=PLCD0445C57F2B7F41

To check what video and audio options are available for download, use:
yt-dlp -F https://www.youtube.com/watch?v=M0yT-LemMik

If the video files available are too large or too low quality for your liking, simply select the best audio and best video file and download them separately:
yt-dlp -f 251 https://www.youtube.com/watch?v=M0yT-LemMik
yt-dlp -f 399-sr https://www.youtube.com/watch?v=M0yT-LemMik

or do it in one command:

yt-dlp -f "251,399-sr" https://www.youtube.com/watch?v=M0yT-LemMik

Then merge them using ffmpeg:
ffmpeg -i "video.mp4" -i "audio.webm" -c copy output.mp4

You can also brush up yourself on the many features yt-dlp has to offer.

Leave a Reply

Your email address will not be published. Required fields are marked *