node-ytdl
node-ytdl copied to clipboard
Defaults to 360p
ytdl does not default to highest quality, it defaults to 360p, and it doesn't seem to want to take any sort of parameter to tell it to do differently.
It would help if the documentation or the built in help explained how quality is supposed to specified.
Regardless, I have downloaded a number of 1080p and up videos, and they all come out as 360p.
Looking into this more, ytdl is taking the top object off of the info.formats array. Which is pretty random. Often times it's the smallest mp4 file, sometimes it's a 'webm' file. I haven't found where this decision is being made in the code yet. But that does seem to be the problem. This video for instance returns webm: https://www.youtube.com/watch?v=ifTZLtJDoaU
item 0 is almost always itag 18, which is the best format that contains both video and audio for a given youtube link. getting a higher quality video wouldn't have audio, so ffmpeg would be required to merge the two sources.
Well, not really. I wrote a function to filter out streams which don't contain both audio and video, then I sorted them based off of width, with widest descending, then returned the itag off the top of the stack. The best quality version of most youtube videos, which have both audio and video, is almost always 720p. Item 0 is usually 360p mp4, and sometimes it's even webm video only (no audio). So, defaulting to item 0 is far from reliable, and it's not necessary, as it's relatively trivial to simply filter and sort for the actual desired default (highest available quality with both audio and video streams). I've thought about making a pull request for my upgrades, and I might if anyone besides me cares about this sort of thing.
The best quality version of most youtube videos, which have both audio and video, is almost always 720p.
That's surprising but great! Please consider submitting a PR; a higher base resolution, if reliable, would be a great addition.