Reputation: 24448
I've been able to adapt some of the examples from here I've found to make the logos shift like TikTok but they only do certain corners. How do you combine these 2 commands into one so that it rotates the logo like Top-Left, Bottom-Right, Top-Right, Bottom-Left and loop until the end of the video? It should work with any resolution like 16:9 or 9:16 etc.
This does Top-Left to Bottom-Right
ffmpeg -i video.mp4 -i watermark.png -filter_complex \
"[0:v][1:v]overlay=x='if(lt(mod(t,10),5),10,W-w-10)':y='if(lt(mod(t,10),5),10,H-h-10)'" \
-codec:a copy out.mp4
This does Top-Right To Bottom-Left
ffmpeg -i video.mp4 -i watermark.png -filter_complex \
"[0:v][1:v]overlay=x='if(lt(mod(t,10),5),W-w-10,10)':y='if(lt(mod(t,10),5),10,H-h-10)'" \
-codec:a copy out.mp4
Now how do you combine them into one and loop.
In addition to combining this, can a text (drawtext) be added under the moving logo as well for a username?
Upvotes: 0
Views: 325
Reputation: 92928
Use
overlay=x='W/2-pow(-1,lt(mod(t,20),10))*((W-w)/2-10)-w/2':y='H/2-pow(-1,lt(mod(t,10),5))*((H-h)/2-10)-h/2'
This will cycle through Top-Left, Bottom-Right, Top-Right, Bottom-Left
. Change the sign in front of pow
to reverse direction.
Upvotes: 1