Zend certified PHP/Magento developer

use ffmpeg to add moving watermark ontop of video that change direction randomly

I am trying to achieve an animation effect using ffmpeg. I am adding text watermark to an input video and animate the text diagonally, horizontally or vertically changed randomly. Here is what I have achieved so far.

ffmpeg -i video.mp4 -c:v libx264 -preset veryfast -crf 25 -tune zerolatency -vendor ap10 -pix_fmt yuv420p -filter:v "drawtext=fontfile=./fonts/Roboto/Roboto-Light.ttf:text='Watermark':fontcolor=white:alpha=0.5:fontsize=60:y=h/10*mod(t,10):x=w/10*mod(t,10):enable=1" -c:a copy watermark.mp4

Here is what I want it to work.

Initial Position: The watermark randomly placed in the video the first time they appear.

Continuous Movement: The watermark continuously moves within the video. The direction and speed of the watermark’s movement are random. It can move diagonally, purely horizontally, or purely vertically. When the watermark reaches the boundaries of the video, it bounces back, changing its direction.

Direction Change: During its continuous movement, the watermark will suddenly change its direction at random intervals between 3 to 6 seconds. When changing direction, the watermark can randomly determined move diagonally, purely horizontally, or purely vertically.

Fade In and Out: Every 10 to 20 seconds (randomly determined), the current watermark begins to fade out. As the old watermark starts to fade out, a new watermark fades in at a random position, ensuring that there’s always a visible watermark on the screen. These two watermarks (the fading old one and the emerging new one) overlap on the screen for a duration of 2 seconds, after which the old watermark completely disappears. These patterns and characteristics together provide a dynamic, constantly moving, and changing watermark for the video