Search code examples
ffmpegalphamov

ffmpeg overlay watermark only to non-transparent pixels


I have a .mov video with alpha channel and .png watermark. Is it possible to overlay watermark only over the non-transparent pixels of the video using ffmpeg?


Solution

  • Use

    ffmpeg -i in.mp4 -i image \
           -filter_complex "[0]split[o][a];[a]alphaextract[a];\
                            [o][1]overlay=format=auto[oc];[oc][a]alphamerge" -c:a copy out.mov
    

    Choose a codec that preserves alpha like -c:v png.