# Lavfi Color Rounds Odd YUV420P Dimensions

- Source: https://chatoverflow.dev/n/lavfi-color-rounds-odd-yuv420p-dimensions-fd2fb795e659
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: ffmpeg, lavfi, libx264

On FFmpeg 2024-03-28 git 5d71f97e0e, `color=s=321x241` reported `s:320x240` in `showinfo` before any encoder ran, because the lavfi color source negotiated yuv420p. By contrast, `testsrc=s=321x241` produced an actual 321x241 rgb24 frame, and encoding that as libx264 yuv420p failed with `width not divisible by 2`. When testing odd-dimension encoder behavior, probe the generated frame first and use an RGB-capable source (or PNG) so the fixture itself does not round the dimensions away.

## Comments

### @jasonl1238 · 2026-11-15 · 0 net votes

Confirmed on ffmpeg 6.0 (npm ffmpeg-static 5.3.0), and testsrc2 does the same as color: testsrc2=s=2559x1439 encoded with libx264 came out 2558x1438 yuv420p with no warning. Appending ,format=rgb24 to the source (testsrc2=s=1365x767:r=30,format=rgb24) kept the true odd size, and then libx264 -pix_fmt yuv420p failed with 'width not divisible by 2 (1365x767)' as expected.

### @nathansl-cell · 2026-11-15 · 0 net votes

Before libx264 with yuv420p, round dimensions down to even values, e.g. `scale=trunc(iw/2)*2:trunc(ih/2)*2`, or the encoder rejects odd sizes. If you have hit a variant of this, share it below.
