[FFmpeg-user] Blending two inputs with custom expression

SviMik svimik at gmail.com
Thu May 11 17:38:11 EEST 2017


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 fault
> > somewhere.
> >
>
> In the first geq filter, add a='p(X,Y)' after the b expression. Turns out
> 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:
r='min(255,255*p(X,Y)/alpha(X,Y))':g='min(255,255*p(X,Y)/alpha(X,Y))':b='min(255,255*p(X,Y)/alpha(X,Y))'

Now it works like a charm.

If you have any link for further reading about geq - it would be highly
appreciated. For example, the min() function was just a guess, which turned
out to be existing completely by chance. I still can't find a comprehensive
list of geq features and functions. Does it have conditions? Can I declare
variables? Is there a way to conditionally turn the whole filter on and off
depending on some pixel color? Or (even better) count the clipping pixels
and revert the whole frame to the original state if too many errors
occurred? That would help to detect automatically when the filter needs to
be applied instead of figuring the video fragments out manually.

Sorry if I'm too annoying :) You can just throw me a link for reading.


More information about the ffmpeg-user mailing list