D
D
Dwellss2021-08-09 01:41:31
fmpeg
Dwellss, 2021-08-09 01:41:31

How to put a watermark on the video at 20 seconds for 5 seconds?

There is such a command, it imposes a moving watermark at 20 seconds for 30 seconds.
But I need the watermark to appear at 20 seconds for 5 seconds and disappear ... How to fix this command?

#!/bin/bash
for file in *.mp4; do
ffmpeg -y -i "$file" -vcodec libx264 -movflags +faststart -threads 0 -r 25 -g 50 -crf 25 -me_method hex -trellis 0 -bf 8 -acodec aac -strict -2 -ar 44100 -ab 128k -f mp4 -vf "movie=/home/domains/test/watermark.png [wm];[in][wm] overlay='if(gte(t,9)*lte(t,29), W-((W+w)/20)*mod(t-9,20), -w-1000)':'0' [out]" "out/$file"
done

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dwellss, 2021-08-09
@Dwellss

In the end, this worked:
ffmpeg -y -i "$file" -i watermark.png -filter_complex \ "[0:v][1:v]overlay=10:10:enable=between(t\,20\, 5)" "out/$file"

S
Sergey Sokolov, 2021-08-09
@sergiks

in your example it's more like between 9 and 29 seconds:
if(gte(t,9)*lte(t,29)
overlay on time compares >= 9 seconds and <= 29
You need it probably if(gte(t,20)*lte(t,25)
AND strings can

endure
ffmpeg \
  -y \
  -i "$file" \
  -vcodec libx264 \
  -movflags +faststart \
  -threads 0 \
  -r 25 \
  -g 50 \
  -crf 25 \
  -me_method hex \
  -trellis 0 \
  -bf 8 \
  -acodec aac \
  -strict \
  -2 \
  -ar 44100 \
  -ab 128k \
  -f mp4 \
  -vf "movie=watermark.png [wm];[in][wm] overlay='if(gte(t,9)*lte(t,29), W-((W+w)/20)*mod(t-9,20), -w-1000)':'0' [out]" \
  "out/$file"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question