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

YouTube slows down video transfer rate - wrong DASH video url? #573

Closed
Isayso opened this issue Jul 8, 2021 · 10 comments
Closed

YouTube slows down video transfer rate - wrong DASH video url? #573

Isayso opened this issue Jul 8, 2021 · 10 comments
Labels

Comments

@Isayso
Copy link

Isayso commented Jul 8, 2021

Version

6.03

Details

I use vlc or Kodi to play the DASH streams extracted with YTExplode and found an unusual behavior. When I play two in a row in a playlist, the 2nd stops all the time and waits for the stream data. I thought it was Kodi or vlc related but I found a discussion about this in the youtube-dl area.

ytdl-org/youtube-dl#29326 (comment)
ytdl-org/youtube-dl#29326 (comment)

Please take a look into this. If I understand this correctly, the video url must be calculated/altered to avoid active throttling from youtube (?)

Steps to reproduce

Please read the discussion from the link above

@Isayso Isayso added the bug label Jul 8, 2021
@Tyrrrz Tyrrrz changed the title youtube slows down video transfer rate - wrong DASH video url? YouTube slows down video transfer rate - wrong DASH video url? Jul 9, 2021
@Tyrrrz
Copy link
Owner

Tyrrrz commented Jul 9, 2021

Are you experiencing slow transfer rates when passing the URL to somewhere or also when you're downloading/streaming a video using YoutubeExplode's own methods (i.e. StreamClient.GetAsync(...) & StreamClient.DownloadAsync(...))?

@Isayso
Copy link
Author

Isayso commented Jul 9, 2021

When I pass the URL to an other program like VLC, the first is running most of the time with the usual speed. If I try to play the next video, the VLC player stops (for buffering) very frequently.
The Kodi Youtube addon has the same issue and it is discussed here

anxdpanic/plugin.video.youtube#163

The performance of YTExplode is ok, if I understand the discussion of the Kodi addon right, the video URL needs some additional parameter to tell Youtube not to slow down the internet connection speed (?)

The YouTube addon of Kodi ist not useable anymore if you want to play more than one video in a row.

@derech1e
Copy link

I recognised a similar issue (maybe the same) with the YoutubeDownloader. Sometimes videos in the webm container takes forever to download. I also couldn't really figure out why it is so, because when I tried to downloaded the same Video with the mp4 Container, it worked perfectly.

@Isayso
Copy link
Author

Isayso commented Jul 12, 2021

Download is affected in the same way. First video fast, 2nd very very slow

@StefH
Copy link

StefH commented Nov 2, 2021

Hello @Tyrrrz,

I've created a POC/workaround/fix for this issue.

My solution is based on this PR (--> descrambling the n query parameter) fent/node-ytdl-core#1022

Note that this a JavaScript project, so I've used https://github.com/paulbartrum/jurassic to evaluate the JavaScript.

1️⃣
I modified a small part of code to save the base.js to disk and reuse this later.
(https://github.com/StefH/Blazor.YouTubeDownloader/blob/1a97dc4e57be74c81d7c052748107a4706057312/YoutubeExplode-master/YoutubeExplode/Videos/Streams/StreamClient.cs#L194)

2️⃣
The code which parses the base.js to extract the JavaScript code responsible to decode the n:
https://github.com/StefH/Blazor.YouTubeDownloader/tree/main/YouTubeUrlDecoder

3️⃣
My example console app which calls all code:
https://github.com/StefH/Blazor.YouTubeDownloader/tree/main/YoutubeExplode.DemoConsole


Note that this is just a POC, if you have more questions please ask these here.

Link to:
ytdl-org/youtube-dl#29326

@StefH
Copy link

StefH commented Nov 4, 2021

I just created a work-around NuGet ...
https://www.nuget.org/packages/YoutubeExplode.Extensions

var streams = await streamClient.GetManifestAndFixStreamUrlsAsync(videoId);

But I guess I'll wait for the PR...

@Tyrrrz
Copy link
Owner

Tyrrrz commented Nov 5, 2021

Hello @Tyrrrz,

I've created a POC/workaround/fix for this issue.

My solution is based on this PR (--> descrambling the n query parameter) fent/node-ytdl-core#1022

Note that this a JavaScript project, so I've used paulbartrum/jurassic to evaluate the JavaScript.

1️⃣ I modified a small part of code to save the base.js to disk and reuse this later. (StefH/Blazor.YouTubeDownloader@1a97dc4/YoutubeExplode-master/YoutubeExplode/Videos/Streams/StreamClient.cs#L194)

2️⃣ The code which parses the base.js to extract the JavaScript code responsible to decode the n: StefH/Blazor.YouTubeDownloader@main/YouTubeUrlDecoder

3️⃣ My example console app which calls all code: StefH/Blazor.YouTubeDownloader@main/YoutubeExplode.DemoConsole

❗ Note that this is just a POC, if you have more questions please ask these here.

Link to: ytdl-org/youtube-dl#29326

Thanks for the tip.

According to the comment here, it seems an alternative workaround is to mask requests with Android user agent. I suggest we do that first and leave the n parameter handling for later because it seems a lot more complex.

#601 (comment)

Open to PRs.

@Isayso
Copy link
Author

Isayso commented Nov 6, 2021

to test it, I need a nuget package. So when you get the video url disguised as an Android device, you get a working link with the right n parameter? (Unfortunately I have not much time these days)

@Tyrrrz
Copy link
Owner

Tyrrrz commented Nov 9, 2021

to test it, I need a nuget package. So when you get the video url disguised as an Android device, you get a working link with the right n parameter? (Unfortunately I have not much time these days)

Allegedly, yes.

@ricebl
Copy link

ricebl commented Nov 20, 2021

It seems the issue has already been pinpointed (to some degree) but I have noticed that even short videos less than a minute will take 15 minutes or more to download if I pick any quality above 480p as an mp4. Downloads still function so not a huge deal, but awaiting testing and updates.

@Tyrrrz Tyrrrz closed this as completed in 4bdbbf2 Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants