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?


1 Answer 1


Based on answers elsewhere and the docs referenced by Gyan:

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 \

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.


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.