Download the lowest quality video with youtube-dl

What's the command to download the least quality video with youtube-dl?

youtube-dl -F shows

format code  extension  resolution note
mp4-56       mp4        audio only   56k , isom container, 0fps, ~7.15MiB
hls-58       mp4        audio only   58k , mp4a.40.2
mp4-385      mp4        640x360     385k , isom container, avc1, 29fps, ~48.80MiB
hls-425      mp4        640x360     425k
mp4-526      mp4        640x360     526k , isom container, avc1, 29fps, ~66.70MiB
hls-572      mp4        640x360     572k
mp4-724      mp4        640x360     724k , isom container, avc1, 29fps, ~91.70MiB
hls-780      mp4        640x360     780k
mp4-1257     mp4        1280x720   1257k , isom container, avc1, 29fps, ~159.00MiB
hls-1337     mp4        1280x720   1337k
mp4-1971     mp4        1280x720   1971k , isom container, avc1, 29fps, ~250.00MiB
mp4-3103     mp4        1920x1080  3103k , isom container, avc1, 29fps, ~394.00MiB
mp4-4147     mp4        1920x1080  4147k , mp42 container, avc1, 29fps, ~526.00MiB (best)

The problem where I can't set -f mp4-385 here is the other videos in the list/playlist have different format code, e.g. the other video shows:

mp4-56       mp4        audio only   56k , isom container, 0fps, ~14.10MiB
hls-58       mp4        audio only   58k , mp4a.40.2
mp4-365      mp4        640x360     365k , isom container, avc1, 29fps, ~91.20MiB
hls-404      mp4        640x360     404k
mp4-493      mp4        640x360     493k , isom container, avc1, 29fps, ~123.00MiB
hls-538      mp4        640x360     538k
mp4-680      mp4        640x360     680k , isom container, avc1, 29fps, ~170.00MiB
hls-733      mp4        640x360     733k
mp4-1174     mp4        1280x720   1174k , isom container, avc1, 29fps, ~293.00MiB
hls-1250     mp4        1280x720   1250k
mp4-1833     mp4        1280x720   1833k , isom container, avc1, 29fps, ~458.00MiB
mp4-2882     mp4        1920x1080  2882k , isom container, avc1, 29fps, ~720.00MiB
mp4-4050     mp4        1920x1080  4050k , mp42 container, avc1, 29fps, ~1012.00MiB (best)

The only similar format code in these two video is the audio-only


Solution 1:

youtube-dl -f worst URL

From the manual under Format Selection:

worst: Select the worst quality format represented by a single file with video and audio

Solution 2:

Usually when we want the worst quality it's to save data, so you actually want the smallest filesize. These aren't always the same as in example:

youtube-dl -f worst https://www.youtube.com/watch?v=5sIWb9GTbbE
[youtube] 5sIWb9GTbbE: Downloading webpage
[download] Destination: Dr Charles Hoffe-5sIWb9GTbbE.mp4
[download] 100% of 20.90MiB in 00:12

youtube-dl https://www.youtube.com/watch?v=5sIWb9GTbbE
[youtube] 5sIWb9GTbbE: Downloading webpage
[download] Destination: Dr Charles Hoffe-5sIWb9GTbbE.f397.mp4
[download] 100% of 9.38MiB in 00:05

worst: 20 MB, default: 9 MB

youtube-dl doesn't have more sophisticated sorting options, but with the fork youtube-dlp you can. This one gives you the file with the smallest filesize

yt-dlp -S '+size,+br'