1

I'm trying to convert all non-transparent pixels of an image to white using the geq filter in ffmpeg: ffmpeg -y -i in.png -vf "format=rgba,geq='r=if(lt(alpha(X,Y),10),255):g=if(lt(alpha(X,Y),10),255):b=if(lt(alpha(X,Y),10),255):a=alpha(X,Y)'" x.png

But ffmpeg is giving me black pixels instead of white. Any ideas what is going on?

in.png:

enter image description here

out.png:

enter image description here

1 Answer 1

1

The two operand if expression returns 0 if the condition isn't met. You need the three operand version.

if(lt(alpha(X,Y),10),255,p(X,Y))
2
  • Thanks, the final one that worked for me is: ffmpeg -y -i in.png -vf "format=rgba,geq='r=if(gt(alpha(X,Y),128),255,0):g=if(gt(alpha(X,Y),128),255,0):b=if(gt(alpha(X,Y),128),255,0):a=if(gt(alpha(X,Y),250),255,0)'" x.png && open x.png
    – user984896
    Sep 24, 2018 at 16:06
  • @user984896 – What should I do when someone answers my question?
    – MarianD
    Aug 7, 2022 at 2:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.