Youtube-dl is an awesome tool for quickly downloading videos from a range of websites. Its intuitiveness makes it very easy for most people to use it without much knowledge of the command line.
Most people primarily use it for downloading Youtube videos but it can get quite annoying when you have a slow internet connection which in turn makes the program download a low-quality video instead of a 1080p or higher video. Here we will show you how to exactly select the quality type and format while downloading Youtube videos with youtube-dl
How to select video quality from youtube-dl?
When downloading a video from Youtube you can select the quality of the video that you want to download in the following way.
- This is how you would normally download a video with youtube-dl.
$ youtube-dl https://www.youtube.com/watch?v=3de64yKeElM
- Now add the flag -F to list the available qualities and formats of the video. Notice the ‘F’ should be in the upper case.
$ youtube-dl -F https://www.youtube.com/watch?v=3de64yKeElM
- The output should be like this –
- Then from the list select your preferred format and use the lowercase f flag along with the format code to download. Here we will download the video in 4k quality which has the format code 315
$ youtube-dl -f 315 https://www.youtube.com/watch?v=3de64yKeElM
- Now your Youtube video will start downloading the preferred format that you chose.
How to download the best quality audio & video from youtube-dl?
Above we showed you how to select to download in a certain quality but how about downloading the best video and audio quality? Here’s how you can do that –
- Use the flag ‘-f bestvideo+bestaudio/best‘ in your command to download the best video and best audio quality.
- Then to encode the audio and video together pass FFmpeg location command along with it ‘–ffmpeg-location [FFmpeg bin location on your device]‘. So the whole command will look something like this –
youtube-dl -f bestvideo+bestaudio/best https://www.youtube.com/watch?v=c9RzZpV460k --ffmpeg-location C:\Users\Downloads\media\ffmpeg-git-full\bin
- This will most probably download a webm or when encoded a mkv file, if you want to download the best quality mp4 file then use this flag ‘-f bestvideo[ext!=webm]+bestaudio[ext!=webm]/best[ext!=webm]’.