UpDownLeftDie/obs-random-videos

Question: How good is the randomness?

proactivematter opened this issue · 1 comments

Hey, thanks for this, it allows for really flexible ways to setup my stream!

The only thing I'd like to understand is regarding how effective the randomization actually is. I get the sense that my video order is fairly consistent across multiple refreshes. In my case I have a folder with 179 videos - I'd think that would be plenty for the algorithm to be effective. I took a look at the html source but I'm not math-savvy enough to make sense of the randomization formula running the show.

Could you offer some insight please? Thank you.

Randomness is based on the random algorithm used in the browser that your streaming software used.
In the case of OBS v27.0.1 it uses Javascript V8 engine version 7.4.288.28

Here is the implementation of the random function used by that version of V8: https://chromium.googlesource.com/v8/v8.git/+/refs/tags/7.4.288.28/src/math-random.cc
I can't really get into much more than that myself. This stuff is written by people a lot smarter than me.
Math.random() is a pseudo-random number generator but it should be good enough for this use though.

You could possibly try doubling the randomization (do it twice, add them together, and divide by 2):
j= Math.floor(((Math.random() * (i + 1)) + Math.random() * (i + 1))/2); (untested)

You could also try replacing it with a cryptographically secure method instead: Crypto.getRandomValues()