Answers.Body: <p>Ended up solving it through <code>scale2ref</code>:</p>
  <pre><code>ffmpeg -y -i video.mov -i watermark.png -filter_complex &quot;[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&quot; -crf 0 -preset ultrafast -c:v mpeg4 -qscale:v 10 -c:a: copy out.mp4`
  </code></pre>
  <p>Where 250 is the width of the overlay in pixels, and 180 its height.</p>
  <p>This outputs a video of N:1280, with an overlay of 250x180 at the bottom-center of it.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-18T18:49:18.383Z
Answers.Text: Why two `$ih`? Was that a typo?
Answers.UserDisplayName: Hashim Aziz
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-19T16:19:29.580Z
Answers.LastActivityDate: 2020-10-19T16:19:29.580Z
Answers.UserDisplayName: mradzinski
Body: <p>I'm trying to scale a video, and then apply an overlay keeping the aspect ration of the same.</p>
  <p>This adds the overlay, but it stretches it to the same aspect ratio of the video which is what I'm trying to avoid:</p>
  <pre><code>ffmpeg -y -i video.mov -i watermark.png -filter_complex &quot;scale=-1:1280:flags=bicubic,overlay=(main_w-overlay_w)/2:main_h-overlay_h&quot; -crf 0 -preset ultrafast -c:v mpeg4 -qscale:v 10 -c:a: copy out.mp4
  </code></pre>
  <p>Any help will be truly appreciated!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-19T05:18:49.447Z
Comments.Text: Unclear. I assume you want both the video and watermark to appear undistorted, right?
Comments.UserDisplayName: Gyan
Tags: <ffmpeg>
Title: FFMpeg: scale and then overlay keeping overlay aspect ratio
UserDisplayName: mradzinski
ThreadText: # FFMpeg: scale and then overlay keeping overlay aspect ratio
  
  (Asked by: username_0 on 2020-10-19)
  
  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!
  
  **Tags:** ffmpeg
  
  > **Comments:**
  > **username_1**: Unclear. I assume you want both the video and watermark to appear undistorted, right?  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-10-19. Score: 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.
  
  > **Comments:**
  > **username_2**: Why two `$ih`? Was that a typo?  
  
  ---
  
  