androidffmpegwatermarkandroid-ffmpegvideo-watermarking

How to add watermark image properly fit XY on video using ffpeg


I am trying to add following watermark image on video using ffpeg but it doesnt fit properly.

Watermark Image

Following is my FFmpeg commond :

String[] complexCommand = {"-i", AppUtils.videoPath, "-i", framelocalPath , "-preset", "ultrafast", "-filter_complex", "overlay=(W-w)/2:(H-h)/2" , dest1.getAbsolutePath()};

But it doesnt fit properly on video, following is my output :

Here is my video with watermark

If anybody can help for overlay with FFmpeg. I also tried different solutions but doesnt help.

Thanks in advance.


Solution

  • Here is the ffmpeg command you should run,

    ffmpeg -i video -i image -filter_complex "[1][0]scale2ref[img][vid];[vid][img]overlay" -preset ultrafast out.mp4
    

    The scale2ref filter resizes the image to match the dimensions of the video. The overlay can then occur at (0,0).