Downloading YouTube videos and playlists with yt-dlp

yt-dlp is a fork from the now troubled youtube-dl, the best part about yt-dlp aside from being actively maintained is that it follows similar commands to youtube-dl.

yt dlp install and usage guide

Installing yt-dlp

Installing yt-dlp can simply be done with:

sudo wget -O /usr/local/bin/yt-dlp

Followed by:

sudo chmod a+rx /usr/local/bin/yt-dlp

If you ever need to update yt-dlp use:

yt-dlp -U

Some common usage examples for yt-dlp:

Print out the available formats and information with:

yt-dlp --list-formats

Print JSON information for the video and audio streams:

yt-dlp --dump-json

Single video or audio downloads

Download the best format (video + audio) that is equal to or greater than 720p width. Save this file as video_id.extension (1La4QzGeaaQ.mp4):

yt-dlp -f "best[height>=720]" -o '%(id)s.%(ext)s'

Download and merge the best video stream with the best audio stream:

yt-dlp -f 'bv*+ba' -o '%(id)s.%(ext)s'

Download 1080p video and merge with best audio stream:

yt-dlp -f 'bv*[height=1080]+ba' -o '%(id)s.%(ext)s'

Download 1080p video that is mp4 format and merge with best m4a audio format:

yt-dlp -f 'bv[height=1080][ext=mp4]+ba[ext=m4a]' --merge-output-format mp4 -o '%(id)s.mp4'

Embed video thumbnail into video file use --embed-thumbnail:

yt-dlp -f 'bv[height=1080][ext=mp4]+ba[ext=m4a]' --embed-thumbnail --merge-output-format mp4 -o '%(id)s.mp4'

Embed subtitles to video file (if they exist) --embed-subs :

yt-dlp -f 'bv[height=1080][ext=mp4]+ba[ext=m4a]' --embed-subs --merge-output-format mp4 -o '%(id)s.mp4'

Embed metadata about the video --embed-metadata :

yt-dlp -f 'bv[height=1080][ext=mp4]+ba[ext=m4a]' --embed-metadata --merge-output-format mp4 -o '%(id)s.mp4'

Get the best audio into mp3 file:

yt-dlp -f 'ba' -x --audio-format mp3 -o '%(id)s.mp3'

All the options for format selection and filtering can be found here, There are a lot.


Download a YouTube playlist with the videos being 1080p and the best audio. Save into channel_id/playlist_id directory with the video added to an archive text file:

yt-dlp -f 'bv*[height=1080]+ba' --download-archive videos.txt -o '%(channel_id)s/%(playlist_id)s/%(id)s.%(ext)s'


Download an entire YouTube channel as 720p video with best audio. Save into a folder named after the channel name with the video files being the title of the video (Foo the Flowerhorn/5 Months Update – Flowerhorn Foods.webm).

yt-dlp -f 'bv*[height=720]+ba' --download-archive videos.txt -o '%(channel)s/%(title)s.%(ext)s'