[FFmpeg-user] How can I simplify these two scale calculations?

Moritz Barsnick barsnick at gmx.net
Fri Aug 7 00:17:28 CEST 2015


On Thu, Aug 06, 2015 at 14:55:47 -0700, ogrgkyle wrote:
> Moritz, thanks for pointing out 1/3 vs. 1/3.3333.  Yes, I wanted 33% (1/3),
> not 30% (1/3.3333).  In the solution you gave (scale=iw/3*sar:ih/3), how can
> I ensure that both dimensions are divisible by 2?  Since they are both
> explicitly defined, I cannot use -2, right?

That's right. Here's the solution which is usually given (it must be in
the docs or the wiki somewhere):

  -vf scale="trunc((iw*sar)/2)*2:trunc(ih/2)*2"

or, in your case (division by 3):

  -vf scale="trunc(iw*sar/6)*2:trunc(ih/6)*2"

(To explain: It does a floating point division by 6, rounds that to an
integer, and doubles it to an even number.)

Moritz


More information about the ffmpeg-user mailing list