ffmpeg/avconv force scaled output to be divisible by 2

Since division by 2 incurs in odd numbers sometimes, it should be:

-vf scale="trunc(oh*a/2)*2:720"

This performs what one would want with -1:720 syntax (keep original aspect ratio)


Actually the filter can handle it directly. You need only to pass -2 instead of -1 to the filter: e.g.

-vf scale="-2:720"

I was surprised to find this out in a bug report from 3 years ago.


After a lot of experimenting it looks like the following filter applied after other scale filters will round the width and height to 2.

scale=trunc(in_w/2)*2:trunc(in_h/2)*2

It's basically a divide, round, multiply thing, I just didn't have the syntax right.

Tags:

Bash

Ffmpeg