0

So I know that one can adjust the rate of download with youtube-dl using the -r or --limit-rate flags; however, as part of a simulation testing, I am trying to simulate a user watching a video , and so I want to download a video at a rate such that the download would take as long as the video's duration is if one were to watch the video, so that a 2min long video would take 2min to download, and so on and so forth.

I have meticulously reviewed the available options on their github page, but it seems like there are no options natively to do that. But then the next best thing I can think of is to get the video duration in seconds (lets call it t) and the video size in bytes (lets call it s) and then use s/t as a value for the --limit-rate flag.

However now the problem is that there doesn't seem to be any options/flags to get the video file-size in bytes!

Is there anyway I can accomplish what my goal is here? I am open to using other tools/programs if this is outside the capabilities of youtube-dl.

To be more specific, I am working in linux server environment (no video-card and needs to be able headlessly), and the videos I'm dealing with are MPEG Dash videos from an MPD file, so whatever tool I use needs to be able to parse and work with MPD files.

Thank you for your help,

Vince Payandeh
  • 383
  • 2
  • 7
  • 2
    [FFmpeg](https://ffmpeg.org/ffmpeg.html) has a `-re` flag that reads the input at the native frame rate. Since MPEG-DASH is adaptive you might also want to select specific streams to simulate the user watching a particular quality. – aergistal Sep 24 '20 at 07:12
  • Thank you so very much. That worked beautifully! pretty much exactly what I needed! – Vince Payandeh Oct 26 '20 at 18:12
  • 1
    Out of curiosity could you not just play the video on your test device and that would download and play it as if a user was watching it. – Mick Dec 04 '20 at 17:36
  • @Mick that would work except that I wanted to have hundreds (or thousands) of such streams simultaneously so I needed something with very low memory and CPU footprint. The ffmpeg suite comes with "ffplay" which does play the video (even can do it headlessly) BUT was still taking up too much CPU. The ffmpeg with '-re' flags takes very small cpu footprint so I've been able to run about 2000 streams of super high quality videos (about 20Gbps total) all simultaneously on an 8 core machine. – Vince Payandeh Dec 05 '20 at 03:04
  • 1
    @VincePayandeh - thanks for the background, and great explanation. Makes sense and nice approach. – Mick Dec 05 '20 at 11:15

0 Answers0