[FFmpeg-user] Blending two inputs with custom expression

SviMik svimik at gmail.com
Thu May 11 19:02:23 EEST 2017

2017-05-11 17:38 GMT+03:00 SviMik <svimik at gmail.com>:
> 2017-05-10 8:07 GMT+03:00 Gyan <gyandoshi at gmail.com>:
> >
> > On Wed, May 10, 2017 at 5:41 AM, SviMik <svimik at gmail.com> wrote:
> >
> > >
> > > Great answer, thank you for the idea! I have tried to run it, and it
> > > produced me a black screen (all zeroes), but I think it may be my
> > > somewhere.
> > >
> >
> > In the first geq filter, add a='p(X,Y)' after the b expression. Turns
> > the geq initializes alpha to 1 if no expression is provided. Ideally, it
> > ought to pass through.
> It works! Thank you so much!
> By the way, I got few pixels with >255 value, and it turns out the ffmpeg
can't handle it itself - the pixel with r=266 value became r=10. So I had
to add min() to the last geq to avoid overflow:
> Now it works like a charm.

I was too fast. I thought that if ffmpeg filter works on an image, then it
should work on the video too. I was wrong. The blend filter makes ffmpeg to
simply drop frames:
frame=    2 fps=0.5 q=-1.0 Lsize=     223kB time=00:00:06.78 bitrate=
268.8kbits/s dup=0 drop=194

I think it tries to process the first frame then fails because the top
layer is png and the bottom is a video. I tried to switch top and bottom
and swap A/B in the expression. Now it doesn't drop the frames, but I
couldn't manage to get the same result on the output. Seems that layer
position is important here, and swapping the layers made the result of the
blending different.

More information about the ffmpeg-user mailing list