Pythonsguru
Pythonsguru

Reputation: 452

watermark on videos like tiktok watermark using ffmpeg

I want to add watermark on video using ffmpeg like tiktok videos, means watermark with logo name and user id and with reflecting diagonally each 5 sec or same interval of time, for simple watermark I am using following command.Please help

ffmpeg -i video.mp4 -i watermark.png -filter_complex "overlay=5:5" out.mp4

Upvotes: 3

Views: 1832

Answers (1)

Ramesh Jangama
Ramesh Jangama

Reputation: 81

Top-Left To Bottom-Right loop:

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

Top-Right To Bottom-Left loop:

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

Idea is very simple

  • Take every 10sec duration, get remainder sec i.e. mod(t,10)
  • if sec < 5, set top position else bottom position

Upvotes: 6

Related Questions