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

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))
| improve this answer | |
  • 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 '18 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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