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

PATCH for the bandwith/trottling issue since 2 weeks #30109

Closed
opossum3003 opened this issue Oct 15, 2021 · 5 comments
Closed

PATCH for the bandwith/trottling issue since 2 weeks #30109

opossum3003 opened this issue Oct 15, 2021 · 5 comments

Comments

@opossum3003
Copy link

Could you make a new switch to control the bandwith (like -r) but only for the first seconds?

YouTube now checks the speed in the first seconds and is reducing the bandwith.
With this algorithm YT detects if you're watching a video or downloading it.

i.E. --limit-start-bandwith 50K --r 10M

This would reduce the bandwith in the first 10 seconds, YT detects that you're watching the stream.
After that you go up to 10Megs and get full speed.

Regards,
Kev

@dirkf
Copy link
Contributor

dirkf commented Oct 16, 2021

Also, the work-around doesn't appear to work. With this patch, the download starts at the limited rate (10k) and after 10s recovers to the throttled rate. So the intended bypass actually makes the download slower.

--- a/youtube_dl/downloader/http.py
+++ b/youtube_dl/downloader/http.py
@@ -25,6 +25,8 @@ from ..utils import (
 
 
 class HttpFD(FileDownloader):
+    limit_start_rate = 10240
+    limit_start_period = 10
     def real_download(self, filename, info_dict):
         url = info_dict['url']
 
@@ -222,6 +224,12 @@ class HttpFD(FileDownloader):
             # measure time over whole while-loop, so slow_down() and best_block_size() work together properly
             now = None  # needed for slow_down() in the first loop run
             before = start  # start measuring
+            if self.limit_start_period:
+                limit_end = before + self.limit_start_period
+                unlimit_rate = self.params.get('ratelimit')
+                self.params['ratelimit'] = self.limit_start_rate
+            else:
+                limit_end = None
 
             def retry(e):
                 to_stdout = ctx.tmpfilename == '-'
@@ -279,6 +287,10 @@ class HttpFD(FileDownloader):
                     return False
 
                 # Apply rate limit
+                if limit_end and limit_end < now:
+                    self.params['ratelimit'] = unlimit_rate
+                    limit_end = None
+
                 self.slow_down(start, now, byte_counter - ctx.resume_len)
 
                 # end measuring of one loop run

@G2G2G2G
Copy link

G2G2G2G commented Oct 17, 2021

as per #29965 use yt-dlp which this issue has been fixed on for a while..

@dirkf
Copy link
Contributor

dirkf commented Oct 19, 2021

Finally, duplicate of #29326 and see also #30097 (comment)

@ghost
Copy link

ghost commented Oct 23, 2021

just use yt-dlp, no one is working on youtube-dl

@ghost
Copy link

ghost commented Oct 28, 2021

just use yt-dlp, no one is working on youtube-dl

Amazing! Thanks!

If somebody needs details of implementation: https://code.videolan.org/videolan/vlc/-/issues/26174#note_286445

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

Successfully merging a pull request may close this issue.

3 participants