3

I'm trying to scale a video, and then apply an overlay keeping the aspect ration of the same.

This adds the overlay, but it stretches it to the same aspect ratio of the video which is what I'm trying to avoid:

ffmpeg -y -i video.mov -i watermark.png -filter_complex "scale=-1:1280:flags=bicubic,overlay=(main_w-overlay_w)/2:main_h-overlay_h" -crf 0 -preset ultrafast -c:v mpeg4 -qscale:v 10 -c:a: copy out.mp4

Any help will be truly appreciated!

1
  • Unclear. I assume you want both the video and watermark to appear undistorted, right?
    – Gyan
    Commented Oct 19, 2020 at 5:18

1 Answer 1

2

Ended up solving it through scale2ref:

ffmpeg -y -i video.mov -i watermark.png -filter_complex "[0:v]scale=-1:1280:flags=lanczos[bg];[1:v][bg]scale2ref=(250/180)*$ih/8/sar:$ih/8[wm][base];[base][wm]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)-overlay_h" -crf 0 -preset ultrafast -c:v mpeg4 -qscale:v 10 -c:a: copy out.mp4`

Where 250 is the width of the overlay in pixels, and 180 its height.

This outputs a video of N:1280, with an overlay of 250x180 at the bottom-center of it.

1
  • Why two $ih? Was that a typo? Commented Oct 18, 2021 at 18:49

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.