3

Currently, I add a watermark to the bottom right of my video to prevent others from republishing it. However, they blur the watermark so I'm thinking of adding a moving watermark that changes its position every x seconds.

Below is my current ffmpeg command:

ffmpeg -i input.mp4 -i logo.png -filter_complex "[1][0]scale2ref=iw/4:ow*90/272[wm][vid];[vid][wm]overlay=W-w-W*10/100:H-h-H*5/100" -preset veryfast output.mp4

How can I make the watermark position from the bottom right to top right, to top left, and bottom left every 30 seconds? Thank you.

David Tran
  • 63
  • 1
  • 9
  • See the 2nd command in my answer at https://superuser.com/q/1413085 – Gyan Nov 05 '19 at 08:37
  • Thank you @Gyan for the answer! I get the idea of changing x and y now. Still I don't understand the use of `5+mod(trunc(((t-12)+1200)/1200),2)` so I don't know what to change to get the result I want. Sorry I'm not familiar with code and command, I was just guessing. Could you please explain what does that mean? I tried to have the position change every 60 seconds with this: `overlay='5+mod(trunc(((t-12)+12)/12),2)*(W-w-W*10/100)':'5+mod(trunc(((t-12)+18)/12),2)*(H-h-H*5/100)':enable='gt(t,12)'` (please read the next comment I have to split it due to the limitation) – David Tran Nov 05 '19 at 13:25
  • However, the position changed every 6 seconds. Also only the bottom watermarks were perfectly positioned. The top watermarks stuck near the video frame without any spaces. How can I make the top left mirror the bottom left, and the top right mirror the bottom right? Sorry again for my noob question. – David Tran Nov 05 '19 at 13:25
  • I'll add an answer over the next couple of days. – Gyan Nov 05 '19 at 18:53
  • Thanks Gyan. Looking forward to your answer! In the meantime I'll try to figure it out. – David Tran Nov 06 '19 at 02:23

1 Answers1

4

The overlay expression, for changing every 30 seconds is,

overlay=x='if(lt(mod(t\,120)\,60)\,W-w-W*10/100\,W*10/100)':y='if(lt(mod(t+30\,120)\,60)\,H-h-H*5/100\,H*5/100)'

This will start from bottom-right and shift clockwise every 30 seconds.

The 2nd arg (120) in the mod function is the period of one rotation. 60 is half-period.

Gyan
  • 85,394
  • 9
  • 169
  • 201