FFmpeg – Partial fade effect on overlay image

I’m having trouble with ffmpeg.

I want to make a 3-second video (example here: streamable.com/7uhi7f) with:

  • A background image (300×350 jpeg file)
  • A logo overlaid in the center of the background image (100×40 png file)
  • And I would like the logo to fade in and out with the following opacity timeline:
  1. At 0 seconds, the opacity is 0.5
  2. At 1 second, the opacity is 1
  3. At 2 seconds, the opacity is 0.2
  4. At 3 seconds, the opacity is 1.

So far I only succeeded in adding an overlay with a fully fade IN (between 0 to 1s) and a fully fade OUT (from 2s to 3s):

ffmpeg -loop 1 -i background.jpeg -framerate 30 -loop 1 -i logo.png -filter_complex "[0]format=rgba,scale=300:250[o];[1]format=rgba,fade=in:st=0:d=1:alpha=1,fade=out:st=2:d=1:alpha=1[i];[o][i]overlay=x=(W-w)/2:(H-h)/2" -c:v libx264 -t 3 output.mp4

I also tried geq & blend filters without any success.

What would be the more appropriate approach to handle that kind of effect?

Read more here: Source link