<p>Found the answer to this problem <a href="https://video.stackexchange.com/a/12111/34632">in here</a>. The mask should be first be white + transparent, instead of black and white. New code would be:</p>
<pre><code>ffmpeg -i video.mp4 -i mask.png \
-filter_complex &quot;[0:v][1:v] overlay=0:0&quot; -c:a copy \
output.mp4
</code></pre>

CC BY-SA 4.0
2021-04-20T09:00:27.613Z
2021-04-21T09:13:23.483Z
2021-04-21T09:13:23.483Z
Clara Ferreira
<p>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.</p>
<p>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:</p>
<p><a href="https://i.sstatic.net/zoKBR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zoKBR.png" alt="enter image description here" /></a></p>
<p>I can almost achieve this using the code:</p>
<pre><code>ffmpeg -i video.mp4 -loop 1 -i mask.png \
       -filter_complex &quot;[0]split[m][a];[m][a]alphamerge[keyed]; \
              [1][keyed]overlay=eof_action=endall&quot; video.mp4
</code></pre>
<p>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.</p>
<p>So specific questions would be:</p>
<ol>
<li><p>Is there a way to make the masked overlay be opaque white?</p>
</li>
<li><p>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 <code>boxblur=5</code>)</p>
</li>
</ol>

CC BY-SA 4.0
2021-04-19T14:58:26.863Z
To get the outcome in the image, swap the order of the inputs.
Gyan
CC BY-SA 4.0
2021-04-19T15:20:47.210Z
Should have clarified better, but I want the outcome in the video, not the image.
Clara Ferreira
<ffmpeg><mask>
FFMPEG - Apply opaque white with mask
Clara Ferreira
# FFMPEG - Apply opaque white with mask

(Asked by: username_0 on 2021-04-19)

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:

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:

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

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)

**Tags:** ffmpeg, mask

> **Comments:**
> **username_1**: To get the outcome in the image, swap the order of the inputs.  
> **username_0**: Should have clarified better, but I want the outcome in the video, not the image.  

---

## 1 answers

### Answer by username_0 on 2021-04-20. Score: 0

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 \
output.mp4


---

