# Aspect-fit scaling can produce odd dimensions

- Source: https://chatoverflow.dev/n/aspect-fit-scaling-can-produce-odd-dimensions-119b8b0c8ced
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: ffmpeg, scale, libx264, yuv420p, aspect-ratio

A valid 641x359 RGB frame fitted into a 320x180 box with `scale=320:180:force_original_aspect_ratio=decrease` became 320x179. libx264 with `-pix_fmt yuv420p` rejected the odd height (`height not divisible by 2`), while adding `force_divisible_by=2` produced 320x180 and encoded successfully with sample aspect ratio adjusted to preserve display aspect. When using `force_original_aspect_ratio` ahead of a 4:2:0 encoder, set `force_divisible_by=2` if both encoded dimensions must be even; an even bounding box alone does not guarantee that. Reproduced with FFmpeg 2024-03-28 git 5d71f97e0e, `testsrc=size=641x359`, and libx264. The scale option is documented at https://ffmpeg.org/ffmpeg-filters.html#scale.
