6

I'm trying to place several overlays on top of each other and fade out the topmost after some frames. Therefore I'm using 2 .png files which should be placed on the final video in the following order:

fademe.png <-- Topmost overlay, should be faded after some frames

overlay.png <-- second overlay, always visible

movie.mov <-- a movie as the bottom layer

I'm using this code to create a PNG encoded .mov from the overlays:

ffmpeg -y -loop 1 -i fademe.png -loop 1 -i overlay.png -filter_complex "[0:0]fade=out:25:25[fad];[1:0][fad] overlay" -vframes 55 -vcodec png overlay.mov

Then I'm using ffmbc to place overlay.mov on top of another video.

(I'm using ffmbc because the final output is going to be ProRes4444)

ffmbc -y -threads 0 -i movie.mov -vf "movie=overlay.mov [watermark]; [in][watermark] overlay [out]"  -vcodec libx264 faded.mp4

The output video looks nice until fading starts and fademe.png [fad] seems to get faded to white and doing some strange things to the colours below until it disappears.

When I'm changing the order in the last overlay from [1:0][fad] overlay to [fad][1:0] overlay so it looks like this:

ffmpeg -y -loop 1 -i fademe.png -loop 1 -i overlay.png -filter_complex "[0:0]fade=out:25:25[fad];[fad][1:0] overlay" -vframes 55 -vcodec png overlay.mov

the fading looks right, but overlay.png [1:0] shouldn't be the topmost layer.

My guess is that something wrong happens to the alpha-channel on my first try.

Any suggestions how to solve this problem?

evilheinz
  • 163

2 Answers2

8

It should not be necessary to use two commands and create an intermediate file with an alpha channel. A single command with 3 inputs, 2 overlay filters, and a fade filter with alpha=1 should do it:

ffmpeg -y -i movie.mov -loop 1 -i overlay.png -loop 1 -i fademe.png \
-filter_complex '[0:v][1:v] overlay [V1]; \
[2:v] fade=out:25:25:alpha=1 [V2]; [V1][V2] overlay' \
faded.mp4
slhck
  • 235,242
mark4o
  • 5,552
2

I think i found a solution:

First I created a intermediate movie of the fading logo

ffmpeg -y -loop 1  -i fademe.png -filter_complex "fade=out:25:25" -vframes 55 -vcodec png fademe.mov

then I used this command with ffmbc

ffmbc -i movie.mov -vf "movie=overlay.png [over]; movie=fademe.mov [fade]; [in][over] overlay [inter]; [inter][fade] overlay [out]" -vcodec libx264 out.mp4

...Heureka!!!

The logo sitting on top of the composition is fading away nice and smooth!

evilheinz
  • 163