LuanRT / YouTube.js

A wrapper around YouTube's internal API — reverse engineering InnerTube
https://www.npmjs.com/package/youtubei.js
MIT License
3.3k stars 199 forks source link

[9.3.0] Formats Urls download speed very slow. (Adaptive format) #652

Open Croodo opened 2 months ago

Croodo commented 2 months ago

Steps to reproduce

const youtube = await Innertube.create({ retrieve_player: false, });

let info = await youtube.getBasicInfo(id, "WEB"); let formats = info.streaming_data.formats

Failure Logs

none

Expected behavior

Normal download speed.

Current behavior

Normal downloading speed when download using the format url .

Version

Default

Anything else?

Adaptive formats download speed is very slow , throttled bellow 100kbps for WEB client. I was previously using ANDROID Client that was very fast. But as of now ANDROID Client not working properly so fallback to WEB client but facing this speed issue.

No VPN/Proxy used.

Is this only me or someone else having the same behaviour?

Checklist

Croodo commented 2 months ago

After doing some investigation found that , throttle depends on the file size, if file size is is low like 1MB or 2MB it will take much longer to throttle and stuck to maximum speed upto 100-200kbps , if file size is like 30Mb it will start with speed of upto 100-200kbps after few chunks it will get faster and to the maximum speed.

LuanRT commented 2 months ago

The adaptive formats need to be downloaded in chunks, otherwise you will get throttled.

https://github.com/LuanRT/YouTube.js/blob/d48b9d0946e4a39f2c6373c4360305e4c5f3efd7/src/utils/FormatUtils.ts#L58

Croodo commented 2 months ago

I'm not directly downloading , I created API , chunk_size can be modified in formats urls to API response?