Fade in and Fade out watermark on a video every x seconds/minutes for y seconds/minutes using FFMPEG
I would like to know if there is a to fade in and fade out watermark on a video every x seconds/minutes for y seconds/minutes using FFMPEG. I have tried the -filter_complex to see if it can help, but I haven't any result.
Solution 1:
You can use the loop filter.
ffmpeg -i video -loop 1 -i logo.png -filter_complex
"[1]trim=0:30,fade=in:st=0:d=1:alpha=1,fade=out:st=9:d=1:alpha=1,
loop=999:750:0,setpts=N/25/TB[w];
[0][w]overlay=shortest=1" out.mp4
First, the logo image stream is trimmed to a duration of x
seconds, here 30. Then a 1-second fade-in and fade-out is applied. The fade-out starts at y-1
seconds, here 9. That result is looped 999 times - use a number sufficient to span the length of the video. Since I've trimmed a 30-second segment, the size of the segment to be looped is duration x framerate
, here 30 x 25
= 750
. The loop starts from the beginning frame 0
. Finally, the loop filter doesn't sanitize the timestamps, so setpts is added to produce a monotonic series.
The stream is then overlaid on the video.