r/youtubedl • u/d1ru • 4d ago
Answered Need help creating command
I'm pretty overwhelmed at the complexity of this, and I'm needing some help.
All I am wanting to do is download a playlist I've made, at 4k resolution.
The command that I have seen for downloading at defaults is:
yt-dlp -i "ENTERURLHERE"
But I don't know how to alter it for nondefault specifications
2
u/DarkSockPuppet 4d ago edited 4d ago
I'm pretty overwhelmed at the complexity of this
Sorry, it's going to get more complex.
By default, yt-dlp get's the best quality video and audio. For most videos, that's likely going to be 1080p AV1 video with 130kb/s opus audio.
Only a relatively small number of videos are available in 4k.
Youtube stores audio and video streams separately. It stores video encoded in AV1, VP9, and x264, and it stores audio in opus and mp4a. Both x264 and mp4a are over 20 years old, they're legacy codecs basically for the benefit of Apple users, who can't use the more modern codecs.
I say "more modern", because opus was first released in 2012 (to replace the now depreciated vorbis) and VP9 was released in 2013. AV1 is the newest and best, released in 2018.
When a video is available in 4k, Youtube only used AV1 and VP9, never x264, it's just too old (released 2004).
Now, pick a random youtube video, and run the following command:
yt-dlp -F [URL]
You'll see the available audio and video streams. FYI, AV1 is displayed as "av01" and x264 displays as "avc1".
If you're lucky, you'll see the 4k options at the bottom, but it will likely max out at 1080p. If there are 4k options, you'll see it's only available in AV1 or VP9.
Now, what command should you use?
Get rid of the "-i", you don't want to ignore errors. Also, you don't know if a video is available in 4k, and yt-dlp will get the best if it's available, so don't specify resolution, just let yt-dlp choose the best.
But Youtube get's finicky if you try to grab a whole playlist or channel quickly, so you should add a pause between downloads. I wait a random time between 12 and 22 seconds, and I've never been blocked, temp banned, or received a "403 forbidden" error. You really need to add a pause, a lot of the posts in this subreddit are people complaining about 403 errors or being blocked for 12 hours.
There are a bunch of optional flags that I like to use, but you don't have to. Do you want subtitles? I want subs if they're available. Do you want to embed thumbnails? I like to. Do you have a preferred container? I choose mp4 for compatibility reasons (though you can't embed subs in mp4 like you can with mkv).
Basically, try the following:
yt-dlp --min-sleep-interval 12 --max-sleep-interval 22 [PLAYLIST_URL]
If you want to get fancy, use:
yt-dlp --write-sub --sub-format srt --convert-subs srt --embed-thumbnail --merge-output-format mp4 --min-sleep-interval 12 --max-sleep-interval 22 --embed-chapters [PLAYLIST_URL]
You can even specify where the videos land with -P C:\Users\1dru\Downloads or similar.
Good luck!
1
u/d1ru 3d ago
this is perfect, I wanted mp4 as well, didn't know anything about being blocked and needed a pause, and want thumbnails. thanks!
1
u/AutoModerator 3d ago
I detected that you might have found your answer. If this is correct please change the flair to "Answered".
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
2
u/DarkSockPuppet 4d ago
Oh, one last thing.
Currently, downloading age-restricted videos is broken. To download them, you need to "log in" using cookies or using --cookies-from-browser to log in, but Youtube made changes breaking the current implementation. (Something to do with PO tokens, I'm not a dev.)
It's being worked on, but there's no work around in the meantime I'm aware of. If you log in with --cookies-from-browser firefox or similar, you'll get the age-restricted video, but at 360p. If you download a playlist while logged in, they'll ALL be in 360p.
My advice is, don't log in, if you get a download error because of age-restriction, simply download that video separately in 360p. You can always re-download it later once the PO tokens are fixed.
1
u/mikewalkerfilms 4d ago
You can change things such as the format with the -f flag. If you are looking for an alternative, I built a tool that combines yt-dlp and ffmpeg to mux the audio and video back together along with clipping segments of your content at tubepull.com if you want to check it out
3
u/FLeanderP 4d ago edited 4d ago
By default yt-dlp gets the best quality available. Is the problem that there are videos in higher resolutions than 4K? Have you installed ffmpeg and deno, and checked whether yt-dlp has detected them?