[FFmpeg-user] Question about random() expression
Jim DeLaHunt
list+ffmpeg-user at jdlh.com
Thu Dec 28 00:59:32 EET 2023
Michael:
On 2023-12-27 13:51, Michael Koch wrote:
> ...I'm using this command line to print four consecutive random numbers:
> ...
I do not have an answer to your question about the behaviour of the
random() function. However, I cannot reproduce your results on my
machine. I get an error complaining about the video filter syntax instead.
> C:\Users\astro\Desktop\LUT1D>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
> ffmpeg version 2023-12-23-git-f5f414d9c4-essentials_build-www.gyan.dev
> Copyright (c) 2000-2023 the FFmpeg developers
> built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
> configuration: --enable-gpl --enable-version3 --enable-static
> --pkg-config=pkgconf --disable-w32threads --disable-autodetect
> --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2
> --enable-gmp --enable-bzlib --enable-lzma --enable-zlib
> --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth
> --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265
> --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx
> --enable-mediafoundation --enable-libass --enable-libfreetype
> --enable-libfribidi --enable-libharfbuzz --enable-libvidstab
> --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm
> --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc
> --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libgme
> --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame
> --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm
> --enable-libopencore-amrnb --enable-libopus --enable-libspeex
> --enable-libvorbis --enable-librubberband
> libavutil 58. 36.100 / 58. 36.100
> libavcodec 60. 36.100 / 60. 36.100
> libavformat 60. 20.100 / 60. 20.100
> libavdevice 60. 4.100 / 60. 4.100
> libavfilter 9. 14.101 / 9. 14.101
> libswscale 7. 6.100 / 7. 6.100
> libswresample 4. 13.100 / 4. 13.100
> libpostproc 57. 4.100 / 57. 4.100
> Input #0, lavfi, from 'color=gray:size=1x1,format=gray':
> Duration: N/A, start: 0.000000, bitrate: N/A
> Stream #0:0: Video: wrapped_avframe, gray, 1x1 [SAR 1:1 DAR 1:1], 25
> fps, 25 tbr, 25 tbn
> Stream mapping:
> Stream #0:0 -> #0:0 (wrapped_avframe (native) -> png (native))
> Press [q] to stop, [?] for help
> 0.000000
> 0.000091
> 0.285346
> 0.929202
> Output #0, image2, to 'out.png':
> Metadata:
> encoder : Lavf60.20.100
> Stream #0:0: Video: png, gray(progressive), 1x1 [SAR 1:1 DAR 1:1],
> q=2-31, 200 kb/s, 25 fps, 25 tbn
> Metadata:
> encoder : Lavc60.36.100 png
> [image2 @ 000001eec3e15700] The specified filename 'out.png' does not
> contain an image sequence pattern or a pattern is invalid.
> [image2 @ 000001eec3e15700] Use a pattern such as %03d for an image
> sequence or use the -update option (with -frames:v 1 if needed) to
> write a single image.
> [out#0/image2 @ 000001eec3e15600] video:0kB audio:0kB subtitle:0kB
> other streams:0kB global headers:0kB muxing overhead: unknown
> frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A
> speed= 1.8x
=====
% 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 ~/tmp/ignore.png
ffmpeg version 4.4.4 Copyright (c) 2000-2023 the FFmpeg developers
built with Apple clang version 14.0.0 (clang-1400.0.29.202)
configuration: --prefix=/opt/local --cc=/usr/bin/clang
--mandir=/opt/local/share/man --enable-audiotoolbox --disable-indev=jack
--disable-libjack --disable-libopencore-amrnb
--disable-libopencore-amrwb --enable-opencl --disable-outdev=xv
--enable-sdl2 --disable-securetransport --enable-videotoolbox
--enable-avfilter --enable-avresample --enable-fontconfig
--enable-gnutls --enable-libass --enable-libbluray --enable-libdav1d
--enable-libfreetype --enable-libfribidi --enable-libmodplug
--enable-libmp3lame --enable-libopenjpeg --enable-libopus
--enable-librsvg --enable-libsoxr --enable-libspeex --enable-libtheora
--enable-libvorbis --enable-libvpx --enable-libzimg --enable-libzvbi
--enable-lzma --enable-pthreads --enable-shared --enable-swscale
--enable-zlib --enable-libaom --enable-libsvtav1 --arch=arm64
--enable-gpl --enable-libvidstab --enable-libx264 --enable-libx265
--enable-libxvid --enable-postproc
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Input #0, lavfi, from 'color=gray:size=1x1,format=gray':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo (Y800 / 0x30303859), gray, 1x1 [SAR 1:1
DAR 1:1], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
Stream #0:0 -> #0:0 (rawvideo (native) -> png (native))
Press [q] to stop, [?] for help
[Parsed_geq_0 @ 0x123705630] [Eval @ 0x16eefcef8] Missing ')' or too
many args in 'st(0'
[AVFilterGraph @ 0x124807b20] Error initializing filter 'geq' with args
'lum=st(0'
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!
=====
This is with FFMpeg 4.4.4 via MacPorts on macOS 12.7.2 Monterey.
Could you perhaps make a simpler command line invocation, which just
runs random() and does not generate a grey image or write a file?
Hope this clears a way to helpful answers,
—Jim DeLaHunt
More information about the ffmpeg-user
mailing list