FFMPEG fades and fades for overlay

I am trying to add Overlay-Pictures to my video via FFMPEG (on Android). For know, I was able to display the image between a certain period of time. But now, in addition, I want to add the fading and fading of the animation. Here is what I still have:

ArrayList<String> cmd = new ArrayList<String>(); cmd.add("-i"); cmd.add("video.mp4"); cmd.add("-i"); cmd.add("../image.png"); cmd.add("-filter_complex"); cmd.add("overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:enable='between(n,1,12)'"); cmd.add("out.mp4"); 

How do I add the Fade in and Fade Out options.

+8
android cmd ffmpeg
source share
1 answer

You are losing image in rgba . Example:

 ffmpeg -f lavfi -i color=color=black -loop 1 -i logo.png -filter_complex "\ [1:0] format=rgba,fade=in:st=0:d=3:alpha=1,fade=out:st=6:d=3:alpha=1 [ovr];\ [0:0][ovr] overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2\ " -t 10 -y out.gif 

format=rgba - use RGB format with alpha for transparency

fade=in:st=0:d=3:alpha=1,fade=out:st=6:d=3:alpha=1 - disappears at start from 0 s for 3 s with alpha, disappears starting from 6 s for 3 s with alpha.

overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2 - overlay centered on the source

enter image description here

+10
source share

All Articles