<p>Based on answers elsewhere and the docs referenced by Gyan:</p>
<pre><code>ffmpeg \                                                                                                               
 -i inputvideo.mp4 \
 -i inputvideo-mask.png \
 -filter_complex &quot;[1:v]format=argb,geq=r='r(X,Y)':a='1.0*alpha(X,Y)'[zork]; \
   [0:v][zork]overlay&quot; \
 -vcodec libx264 \
 outputvideo.mp4
</code></pre>
<p>This takes a input video <code>inputvideo.mp4</code> and the overlay image <code>inputvideo-mask.png</code>, combines the two and then create the output video <code>outputvideo.mp4</code>.</p>
<p>Note, you can change opacity of the layer by changing the <code>1.0</code> in the <code>1.0*alpha(X,Y)</code> part of the parameters, where value is 0.0-1.0. For the other parameters I can't provide more information, without needing to refer to the docs.</p>
<p>Tested with ffmpeg 4.4 on macOS 11.4.</p>

CC BY-SA 4.0
2021-08-26T20:28:40.953Z
2021-08-26T20:28:40.953Z
Andre M
<p>We would like to overlay an image throughout the whole video file we have. We no longer have access to the original source, so need to modify the video we have. The current video is in MP4 format.</p>
<p>The way we are thinking of going about it is taking an image, in PNG format with transparency, in the same dimensions of the video and then combining it with the source video to create the output we need.</p>
<p>Can anyone suggest how to go about this with ffmpeg?</p>

CC BY-SA 4.0
2021-08-18T04:26:14.370Z
Have you seen the docs, especially the docs?  http://www.ffmpeg.org/ffmpeg-filters.html#overlay-1
Gyan
<ffmpeg>
Overlay transparent image (png) over video (mp4) with ffpmeg?
Andre M
# Overlay transparent image (png) over video (mp4) with ffpmeg?

(Asked by: username_0 on 2021-08-17)

We would like to overlay an image throughout the whole video file we have. We no longer have access to the original source, so need to modify the video we have. The current video is in MP4 format.

The way we are thinking of going about it is taking an image, in PNG format with transparency, in the same dimensions of the video and then combining it with the source video to create the output we need.

Can anyone suggest how to go about this with ffmpeg?

**Tags:** ffmpeg

> **Comments:**
> **username_1**: Have you seen the docs, especially the docs?  http://www.ffmpeg.org/ffmpeg-filters.html#overlay-1  

---

## 1 answers

### Answer by username_0 on 2021-08-26. Score: 0

Based on answers elsewhere and the docs referenced by username_1:
ffmpeg \                                                                                                               
 -i inputvideo.mp4 \
 -i inputvideo-mask.png \
 -filter_complex "[1:v]format=argb,geq=r='r(X,Y)':a='1.0*alpha(X,Y)'[zork]; \
   [0:v][zork]overlay" \
 -vcodec libx264 \
 outputvideo.mp4

This takes a input video inputvideo.mp4 and the overlay image inputvideo-mask.png, combines the two and then create the output video outputvideo.mp4.
Note, you can change opacity of the layer by changing the 1.0 in the 1.0*alpha(X,Y) part of the parameters, where value is 0.0-1.0. For the other parameters I can't provide more information, without needing to refer to the docs.
Tested with ffmpeg 4.4 on macOS 11.4.


---

