This seems like a simple thing to do, but for my life I cannot find an answer that does this the way I need to.

Using a mask image, I want to make the white parts of the mask still be white (not transparent) in the video output, while the black pixels of the mask would not appear in the output. This would make it easier for a particle tracking software to work properly as there would be no confounding particles coming from the background+text. Like so:

enter image description here

I can almost achieve this using the code:

ffmpeg -i video.mp4 -loop 1 -i mask.png \
       -filter_complex "[0]split[m][a];[m][a]alphamerge[keyed]; \
              [1][keyed]overlay=eof_action=endall" video.mp4

However, the result is not an opaque white due to the overlay function, and I would further need to blur it as the clock is still very visible and becomes a new trackable particle.

So specific questions would be:

  1. Is there a way to make the masked overlay be opaque white?

  2. Alternatively, is there a way I could still use the code above but make just the white part of the mask blurred? (right now, it blurs everything if I add boxblur=5)

  • To get the outcome in the image, swap the order of the inputs.
    – Gyan
    Apr 19, 2021 at 14:58
  • Should have clarified better, but I want the outcome in the video, not the image. Apr 19, 2021 at 15:20

1 Answer 1


Found the answer to this problem in here. The mask should be first be white + transparent, instead of black and white. New code would be:

ffmpeg -i video.mp4 -i mask.png \
-filter_complex "[0:v][1:v] overlay=0:0" -c:a copy \

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.