I use ffmpeg to add a flip watermark on the wideo with overlay
,
This works well with x
ffmpeg -hide_banner -i HLS_540.ts -i out.png -filter_complex "[0:v][1:v]overlay=x='-w+400+100*mod(t\,(W+w-400)/100)':y=250" out.mp4
But when I set y
with expression if(eq(mod(t,5),0),rand(0,100),y)
it show's error.
ffmpeg -hide_banner -i HLS_540.ts -i out.png -filter_complex "[0:v][1:v]overlay=x='-w+400+100*mod(t\,(W+w-400)/100)':y='if(eq(mod(t\,5)\,0)\,rand(0\,100)\,y)'" out.mp4
[Parsed_overlay_0 @ 000002438ba6d880] [Eval @ 000000cf5a3fe2e0] Unknown function in 'rand(0,100),y)'
[Parsed_overlay_0 @ 000002438ba6d880] Error when evaluating the expression 'if(eq(mod(t,5),0),rand(0,100),y)' for y
[Parsed_overlay_0 @ 000002438ba6d880] Failed to configure input pad on Parsed_overlay_0
While when I do like this ffplay -f lavfi -i "color=color=yellow" -vf "drawtext=text='s':x=if(eq(mod(t\,5)\,0)\,rand(0\,(W-tw))\,x+0.03*mod(t\,5)):y=if(eq(mod(t\,5)\,0)\,rand(0\,(H-th))\,y)"
it works well.
How can I set rand y
in the failed command?
Envirionment: win11, git-bash
ffmpeg -version
ffmpeg version N-104863-g6cf55b9da2-20211213 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11.2.0 (crosstool-NG 1.24.0.498_5075e1f)
configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librist --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20211213
libavutil 57. 11.100 / 57. 11.100
libavcodec 59. 14.100 / 59. 14.100
libavformat 59. 10.100 / 59. 10.100
libavdevice 59. 0.101 / 59. 0.101
libavfilter 8. 20.100 / 8. 20.100
libswscale 6. 1.101 / 6. 1.101
libswresample 4. 0.100 / 4. 0.100
libpostproc 56. 0.100 / 56. 0.100
The expr function rand(min,max)
is specific to drawtext and not generic.
The generic function is random(x)
which returns a value between 0 and 1.
x
is any integer between 0 and 9 where the filter will store its PRNG seed.
So, in overlay you would use 0+(100-0)*random(9)
in place of rand(0\,100)