56

So I'm trying to download an entire youtube channel using youtube-dl. I know that if you use the -F command, it gives you a list of the quality type of the videos. My question is this: how to download the best quality of all the videos so the download doesnt default to 460p or something low like that.

103

This answer won't work on older versions of youtube-dl. You need to update youtube-dl to the latest version. You can either install the latest version of youtube-dl locally inside a Python virtual environment (virtualenv), or you can download the latest version of youtube-dl and install it with pip (sudo apt remove youtube-dl && sudo apt install python-pip && pip install --user youtube-dl). youtube-dl is also a snap package. To install it type:

sudo snap install youtube-dl # launch it with snap run youtube-dl

Open the terminal and type:

youtube-dl -f best -ciw -o "%(title)s.%(ext)s" -v <url-of-channel>

...where <url-of-channel> is replaced by the URL of the channel.

Note: If you are downloading a lot of videos, you should change directories to the directory where you want to save the videos before you start downloading them.

Explanation

-f, --format FORMAT
    video format code. The special name "best" will pick the best quality.

-c, --continue                   
    force resume of partially downloaded files

-i, --ignore-errors              
    continue on download errors, for example to skip unavailable videos in a channel 

-w, --no-overwrites
    do not overwrite files

-o, --output
    Output filename template, this example functions similarly to the old --title option

-v, --verbose
    print various debugging information
14
  • 1
    That was a good answer. Maybe if you just want to update it because I applied that command and I got this warning WARNING: --title is deprecated. Use -o "%(title)s-%(id)s.%(ext)s" (but your command worked successfully despite the warning) Jan 28 '18 at 11:00
  • @karel since the channel that i wanna download contains ,many videos thus i can't download them in one sitting. What to do in such case?
    – Vicrobot
    Jul 18 '18 at 14:34
  • 6
    You should also add --download-archive downloaded.txt to resume downloading - this will skip existing files Jun 25 '19 at 22:31
  • 2
    As of today, -f best option WILL NOT give you the best resolution. You would be better off in removing that flag. Check with and without before queuing your batch download.
    – nehem
    Nov 11 '19 at 13:08
  • 1
    Wanted to chime in and mirror what @nehem said. I'm on Windows 10 with the May 8th, 2020 build of youtube-dl and removing -f best did indeed bump the quality of the downloads significantly. May 10 '20 at 15:26
13

TL;DR use the -f 'bestvideo[height>=720]+bestaudio/best' flag to get a higher resolution. The full command I used is:

youtube-dl -f "bestvideo[height>=720]+bestaudio/best" -ciw -o "%(title)s.%(ext)s" -v <url-of-channel>

Here is why -f best might not give you the highest resolution.

When you use the -F flag to list the possible file formats, sometimes it lists a 360p format as "best", for example:

youtube-dl -F https://www.youtube.com/watch?v=FmZXCqqx6q0
[youtube] FmZXCqqx6q0: Downloading webpage
[info] Available formats for FmZXCqqx6q0:
format code  extension  resolution note
249    webm   audio only tiny   61k , opus @ 50k (48000Hz), 12.74MiB
250    webm   audio only tiny   80k , opus @ 70k (48000Hz), 16.87MiB
140    m4a    audio only tiny  132k , m4a_dash container, mp4a.40.2@128k (44100Hz), 31.35MiB
251    webm   audio only tiny  158k , opus @160k (48000Hz), 33.34MiB
...
244    webm   854x480    480p  271k , vp9, 30fps, video only, 35.05MiB
398    mp4    1280x720   720p  443k , av01.0.05M.08, 30fps, video only, 102.27MiB
247    webm   1280x720   720p  480k , vp9, 30fps, video only, 63.02MiB
136    mp4    1280x720   720p  489k , avc1.4d401f, 30fps, video only, 114.12MiB
18     mp4    640x360    360p  360k , avc1.42001E, 30fps, mp4a.40.2@ 96k (44100Hz), 87.29MiB (best)

As you can see the last option is listed as the best despite it's low resolution. There are a few ways we can get around this, I was trying to download from a channel that uploads in 720p so the easiest way was for me to use the -f 'bestvideo[height>=720]+bestaudio/best' flag.

Depending on your situation you might have to play with the format selector expression, perhaps either increasing it from 720 to 1080 or selecting a specific file format like mp4.

To see other format selector examples

To see a full breakdown of the options

You will need to install ffmpeg or convert from mkv.

1
  • I would have made this a comment to the other thread, but you can't contribute without 50 reputation.
    – smile-eh
    Jun 1 '20 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.