<p>The scale filter has an option called <code>force_divisible_by</code> for this,</p>
<p><code>scale=w=1280:h=720:force_original_aspect_ration=decrease:force_divisible_by=2</code></p>

CC BY-SA 4.0
2021-07-18T04:10:18.023Z
2021-07-18T04:10:18.023Z
Gyan
<p>I am using ffmpeg to scale video files to fit within a size of 1280:720, maintaining aspect ratio, using the below commands. This works most of the time, but every now and then a video with a weird aspect ratio comes out to a scale that is not a multiple of 2 in one of the dimensions, which throws an error when encoding to h.264. Is there a way I can keep the same scaling logic but round off that dimension to a multiple of 2?</p>
<p>By way of example I am currently erroring on a video which is 4:3 720:486 - which scales to 1067:720.</p>
<p><code>-i input.mov -c:v libx264 -vf scale=w=1280:h=720:force_original_aspect_ration=decrease output.mov</code></p>

<ffmpeg>
ffmpeg scale, force multiple of 2
Spencer
# ffmpeg scale, force multiple of 2

(Asked by: username_0 on 2021-07-17)

I am using ffmpeg to scale video files to fit within a size of 1280:720, maintaining aspect ratio, using the below commands. This works most of the time, but every now and then a video with a weird aspect ratio comes out to a scale that is not a multiple of 2 in one of the dimensions, which throws an error when encoding to h.264. Is there a way I can keep the same scaling logic but round off that dimension to a multiple of 2?

By way of example I am currently erroring on a video which is 4:3 720:486 - which scales to 1067:720.

`-i input.mov -c:v libx264 -vf scale=w=1280:h=720:force_original_aspect_ration=decrease output.mov`

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2021-07-18. Score: 2 | Accepted answer

The scale filter has an option called `force_divisible_by` for this,

`scale=w=1280:h=720:force_original_aspect_ration=decrease:force_divisible_by=2`


---

