0

sorry if my question is not exactly the correct format, this is my first post here

I have created a ffmpeg one line code that will fade in and fade out a transparent .png as a overlay

here is my code:

bin\ffmpeg -t 10 -i "video w bottom.mp4" -i "utube watermark.png" -filter_complex "[1:v]format=rgba,geq=r='r(X,Y)':a='0.75*alpha(X,Y)',scale=150:150,zoompan=d=25*4:d=125:s=150x150,fade=in:st=2:d=1:alpha=1,fade=out:st=4:d=1:alpha=1[im];[0][im]overlay=10:10:enable='between(t,0,5)'" -c:a copy preview.mp4

now this works great! BUT... the issue i am having is if i try and change up the here:

fade=out:st=4 and enable='between(t,0,5)

then it no longer fades out correctly if say i change it to:

fade=out:st=5 and enable='between(t,0,6)

EDIT: Here is the final code with with the info i got from @Gyan (I am sure can be cleaned up better)

SET /A overlayStart=2
SET /A overlayLength=6
SET /A fadeInDuration=1
SET /A fadeOutDuration=1
SET /A fps=30

SET /A startOverlayFadeIn=%overlayStart%
SET /A startOverlayFadeOut=%overlayStart%+%overlayLength%
SET /A betweenEnding=%startOverlayFadeOut%+%fadeInDuration%
SET /A overlayFullLength=%overlayStart%+%overlayLength%+%fadeInDuration%+%fadeOutDuration%
SET /A dur=%overlayFullLength%+4

bin\ffmpeg -t %dur% -i "video w bottom.mp4" -i "utube watermark.png" -filter_complex "[1:v]format=rgba,geq=r='r(X,Y)':a='0.75*alpha(X,Y)',scale=150:150,zoompan=d=%fps%*%overlayFullLength%:s=150x150,fade=in:st=%startOverlayFadeIn%:d=%fadeInDuration%:alpha=1,fade=out:st=%startOverlayFadeOut%:d=%fadeOutDuration%:alpha=1 [im];[0][im]overlay=10:10:enable='between(t,0,%dur%)'" -c:a copy preview.mp4

Hope this helps someone else out and/or they can expand on this

1 Answer 1

0

In zoompan, you have set d=125 so @ 25 fps, zoompan will create a 5-second stream.

Thus there are no frames after 5s for the fade to be applied to. The duration of the stream should be enough to cover the end of the fade transition. For st=5:d=1, total duration should be 5+1=6 or more.

Change to d=150.

P.S. In d=25*4:d=125 the first d=VALUE is overridden by the 2nd one, so it is useless.

2
  • I will make a edit of the full code in the OP in case this can help someone else. Thank you Dec 14, 2020 at 8:06
  • how can i set this up to run by say 2-3 times? from a variable i set of %c% times? do i need to ask a new question? @gyan Dec 14, 2020 at 21:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.