[FFmpeg-user] Question about random() expression

Michael Koch astroelectronic at t-online.de
Thu Dec 28 00:10:25 EET 2023


Am 27.12.2023 um 23:04 schrieb Devin Heitmueller:
> On Wed, Dec 27, 2023 at 4:51 PM Michael Koch
> <astroelectronic at t-online.de> wrote:
>> Hi,
>>
>> I'm using this command line to print four consecutive random numbers:
>>
>> ffmpeg -loglevel repeat -f lavfi -i color=gray:size=1x1,format=gray -vf
>> geq=lum='st(0,0.123);print(random(0));print(random(0));print(random(0));print(random(0));0'
>> -frames 1 -y out.png
>>
>> The output is always the same four numbers:
>> 0.000000
>> 0.000091
>> 0.285346
>> 0.929202
>>
>> Why is the first number always zero, even if I write different seed
>> values (here: 0.123) into variable 0?
> From: https://ffmpeg.org/ffmpeg-utils.html
>
> "Return a pseudo random value between 0.0 and 1.0. x is the index of
> the internal variable which will be used to save the seed/state."
>
> If you're looking for a value between 1 and N, you can probably just
> multiply it by N (i.e. N=1000, 0.285 * 1000 = 285).

In my example I'm using the index x=0 and I did set the seed value to 
0.123.
It's clear that the random function returns values between 0 and 1.
My question is why the seed value is ignored.

Michael



More information about the ffmpeg-user mailing list