[FFmpeg-user] Question about random() expression

Devin Heitmueller devin.heitmueller at ltnglobal.com
Thu Dec 28 00:04:14 EET 2023


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).

Devin

-- 
Devin Heitmueller, Senior Software Engineer
LTN Global Communications
o: +1 (301) 363-1001
w: https://ltnglobal.com  e: devin.heitmueller at ltnglobal.com


More information about the ffmpeg-user mailing list