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?


enter image description here


enter image description here

1 Answer 1


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

  • 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
    Commented Sep 24, 2018 at 16:06
  • @user984896 – What should I do when someone answers my question?
    – MarianD
    Commented Aug 7, 2022 at 2:03

Your Answer

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

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