1

I have an FFmpeg command in a script that crossfades a main video with an outro and then overlays a semi-transparent PNG watermark on top of it.

ffmpeg -y -i "$1" -i "outro.mp4" -i "../Watermark/watermark3.png" \
-filter_complex \
"color=black:$res:d=$total[base]; \
[0:v]scale=-2:'max(720,ih)',setpts=PTS-STARTPTS[v0]; \
[1:v]format=yuva420p,fade=in:st=0:d=$fadeduration:alpha=1,setpts=PTS-STARTPTS+(($fadetime)/TB)[v1]; \
[2:v]lut=a=val*0.7[v2]; \
[v2][v0]scale2ref=w=oh*mdar:h=ih*0.1[wm_scaled][vidtmp1]; \
[base][vidtmp1]overlay[tmp]; \
[tmp][v1]overlay,format=yuv420p[tmp2]; \
[tmp2][wm_scaled]overlay=W-w-50:50:format=auto,format=yuva420p[outv]" \
-map "[outv]" -map 0:a:0 -c:v libx264 -crf 17 -c:a copy "$output"

This works well enough, but I want the overlay to a) only display on the main video, and b) fade in and out.

However, trying to add the necessary fade filters to the watermark:

[2:v]lut=a=val*0.7,fade=in:st=5:d=2:alpha=1,fade=out:st=150:d=2:alpha=1[v2];

...simply fails silently, producing a working output with no watermark to be seen at all.

What's going on here?

0

1 Answer 1

2

It turns out the reason for this annoying and - for me - longstanding issue was caused by the PNG technically having no frames: because it has no frames it has nothing to animate, and therefore nothing to fade in or out.

It's annoying that there's no error-checking for this and that the overlay is simply dropped from the stream, but either way it's very simply solved by adding a -loop option directly before the path to the image:

-i source.mkv -i outro.mp4 -loop 1 -i watermark.png ...

You may also need to add the shortest=1 option to the overlay filter when applying the overlay, to make sure that the overlay stops with the end of the video rather than going on to loop indefinitely:

[mainvid][watermark]overlay=W-w-50:50:shortest=1[outv];

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .