Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video Takes a Long Time to Load - Same video performs differently daily #551

Open
joebcvan90 opened this issue Oct 11, 2021 · 11 comments
Open

Comments

@joebcvan90
Copy link

On some days, the video would load very quickly and play right away, but on some days, the video takes more than 15 seconds to load. Tested this under both WIFI and cellular, but I had the same results. It's the same video performing differently on a daily basis. I tried looking everywhere, but couldn't figure out where the problem is coming from.

Can anyone help with this issue?
Many thanks in advance.

@joebcvan90 joebcvan90 changed the title Video Takes a Long Time to Load Video Takes a Long Time to Load - Same video performs differently depending on what day it is Oct 11, 2021
@joebcvan90 joebcvan90 changed the title Video Takes a Long Time to Load - Same video performs differently depending on what day it is Video Takes a Long Time to Load - Same video performs differently daily Oct 11, 2021
@fightveryexplosion
Copy link

I've been experiencing this since about a week ago as well.
This has been a topic of discussion in youtube-dl for a while, and it seems like YouTube sometimes randomly throttles the download speed for a URL to about 50~70kb.
If you retry by getting a new URL (by executing a new XCDYoutubeKit request) a couple of times it eventually will get a URL that is capable of a normal download speed, but this can sometimes take up to 10 tries and is not exactly a pretty solution.

There seems to be a specific parameter (n) in the mp4 URL that is encrypted, and if this encryption is solved you will be able to get a steady URL every time, but this encryption method seems to vary depending on the video and I have not found a way to solve it on iOS.
According to the youtube-dl discussion, this has been solved in another python library called yt-dlp, where I guess they have managed to crack the encryption.

If anyone has a solution I would be thrilled to hear about it.

@huynguyencong
Copy link

huynguyencong commented Oct 12, 2021

I have been experiencing this issue. It takes 30-60s to play a video.

@dim4ikhot
Copy link

Facing with the same issue, but time is MUCH longer. To play the 5-6 minutes video it takes up to 7 minutes to load it... Awful. The WebView approach works better, but the configuration much worse. But nothing have to do, except switch to WebView solution

@cbg-dev-k
Copy link

cbg-dev-k commented Oct 21, 2021

Thanks for the suggestion @fightveryexplosion

I applied some changes from ytdlp which seem to fix the slowdown. Feel free to try it out in #552

Edit: I didn't do anything encryption related, it's just a different API and some parameter tweaks.

@huynguyencong
Copy link

@kbex-dev I tried your code, but I see it still slow to load a video.

@cbg-dev-k
Copy link

@huynguyencong That's disappointing. We haven't noticed any throttled videos in our testing (20+ videos) whereas we encountered it almost every time before.

Do you have a video link I can try on my end?

@huynguyencong
Copy link

@kbex-dev For example this one: https://www.youtube.com/watch?v=t4H_Zoh7G5A . It take more than 20s but can't play.

This is the pod in my Pod file:
pod 'XCDYouTubeKit', :git => 'https://github.com/kbex-dev/XCDYouTubeKit.git'

@frozenthrone
Copy link

@huynguyencong That's disappointing. We haven't noticed any throttled videos in our testing (20+ videos) whereas we encountered it almost every time before.

Do you have a video link I can try on my end?

often buffing at 50-70 kb/s

@cbg-dev-k
Copy link

I did some testing on VPN (until I ran out of free data). It seemed to work better on US and EU regions than Asia. Where are you connecting from @frozenthrone? I won't be able to spend more time on this, since it seems to work for our target regions.

It may be worth testing what APIs yt-dlp uses and what speed you get with it? Perhaps they do something different depending on region.

@philmmoore
Copy link

pod 'XCDYouTubeKit', :git => 'https://github.com/kbex-dev/XCDYouTubeKit.git'

This worked for me, thanks allot @kbex-dev

The package has been pretty unreliable over the last few months 👎

@gassan
Copy link

gassan commented Feb 14, 2022

The same for me.
The caching takes up several minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants