1

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

1 Answer 1

0

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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