phpvideoffmpegvideo-conversion

Adjusting watermark according to video resolution using ffmpeg


I have a question related to video conversion I am trying to add watermark to different high resolution videos using ffmpeg and its getting added pretty fine but the issue is same watermark gets bigger on low resolution videos which was looking fine with high resolution video.Is there any possible way i can scale watermark according to video resolution?.I am sure there is but I seem to be pretty blank in this area any help regarding this issue would be really appreciated.

This is the command that i am using to add watermark in my php script

/usr/bin/ffmpeg -i /var/www/html/demo/files/conversion_queue/15490094394e7a7.mp4 -i /var/www/html/demo/upload/images/watermark.png -filter_complex 'overlay=10:10' -y /var/www/html/cb_corp_git/upload/files/conversion_queue/15490094394e7a7-wm.mp4 

Solution

  • Use the scale2ref filter as follows:

    ffmpeg -i video.mp4 -i watermark.png -filter_complex "[1][0]scale2ref=w='iw*5/100':h='ow/mdar'[wm][vid];[vid][wm]overlay=10:10" output.mp4
    

    This will proprortionally scale the watermark width to 5% of the video width, and then overlay the resized watermark.