FFmpeg height not divisible by 2: why and how to fix it
The error means a yuv420p encode got an odd height (or width). Make both even: scale with -2 or round with trunc(ih/2)*2. How Sume rounds sizes.

"Height not divisible by 2" means the video you are encoding in yuv420p has an odd height; an odd width gives the matching width error. yuv420p stores color at half the picture's width and half its height, so both sides have to be even. Make the size even: give the computed side as -2 in the scale filter (scale=1280:-2), or round an odd frame down with scale=trunc(iw/2)*2:trunc(ih/2)*2.
The FFmpeg facts come from its filters, ffmpeg, and utilities documentation and its pixfmt.h reference, and Sume's from the Video filter, Video trim, and Timeline 1.0 docs and the Sume API reference, read on 2026-09-28. Anything described as current behavior is read from Sume's code.
Why does yuv420p need even dimensions?
In a 4:2:0 format such as yuv420p, each 2×2 block of pixels shares one set of color samples, so the color planes are half as wide and half as tall as the picture. FFmpeg calls these factors the chroma subsample values, hsub and vsub. One of its scale examples rounds a size to multiples of them, and another makes the resolution even, which it notes is required by some codecs. An odd side leaves a half block that the encoder won't take.
The odd number comes from whatever set the size: a scale that computed one side, a crop, or a source that was already odd. Fix it at the step that sets the size.
How do I fix it with the scale filter?
Pick the form that matches how you set the size. What each one does comes from FFmpeg's scale filter documentation:
| Scale value | What it does |
|---|---|
scale=1280:-2 | Sets the width and computes the height from the aspect ratio, then makes it divisible by 2. Any -n makes the computed side divisible by n; the side you set stays as written, so make it even too. |
scale=1280:-1 | Also keeps the aspect ratio, but -1 only makes the side divisible by 1, so it can come out odd. |
scale=trunc(iw/2)*2:trunc(ih/2)*2 | Keeps the frame size and rounds an odd width or height down to even. iw and ih are the input width and height. |
scale=400:300:force_original_aspect_ratio=decrease:force_divisible_by=2 | Fits the video inside 400×300 at even dimensions, keeping the aspect ratio. |
# Width 1280, height from the aspect ratio, rounded to even
ffmpeg -i input.mp4 -vf scale=1280:-2 -c:v libx264 -pix_fmt yuv420p -c:a copy output.mp4
# Keep the size, but round an odd width or height down to even
ffmpeg -i input.mp4 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -c:v libx264 -pix_fmt yuv420p -c:a copy output.mp4What about the crop filter?
FFmpeg's crop filter rounds for you by default, but only on a subsampled video. Its exact option defaults to 0, and while it's off, a subsampled video's crop width, height, and position are rounded down to the nearest smaller value instead of being used exactly as given. A source without chroma subsampling, such as yuv444p, gets no such rounding, so an odd crop there reaches the yuv420p encode still odd. In that case, and whenever you set exact=1, keep the numbers even yourself, for example with trunc(iw/2)*2-style expressions.
How does Sume handle odd sizes?
Sume's trim, filter, and Timeline tools read your workspace's media.sume.com files, such as an earlier Sume job's output. An exact trim writes H.264 in yuv420p, per its docs, and in current code so do video filter and Timeline, so their output sizes have to be even too. Here is how each one handles it:
- Video filter's
cropop takes the rectangle as fractions of the source frame, and the compiler even-rounds it for yuv420p. How to crop a video without losing quality shows the op. - Video trim's
outputtakes a width and height from 256 to 2160. In current code, each is rounded down to an even number, and if you set only one side, the other is computed with-2to keep the aspect ratio. Withoutoutput, anexacttrim keeps the source's size as it is, so sendoutputif the source itself is odd. - Timeline 1.0's
output.widthandoutput.heightmust be even integers from 256 to 2160, and in current code Timeline compose's output size must be even too. Change a video's frame rate or resolution covers both. - A raw
filtergraphon video filter is yours to keep even.scaleis on the filter allowlist, and the freePOST /v1/video-filter/checkruns the schema and allowlist checks without touching the encoder, so a program that passes it can still fail when it runs. Use-2ortrunc(iw/2)*2in any size you compute.
Sources
Related posts
More in Developers
- FFmpeg merge audio and video: -map, copy, and -shortest
Merge audio and video with FFmpeg: map the video from one file and the audio from the other, copy the video, and add -shortest to match lengths.
- FFmpeg trim video: cut by time, with or without re-encoding
Trim a video with FFmpeg: -ss before -i to seek, -t for the length, and -c copy to skip re-encoding, which starts the cut at the keyframe before.
- Higgsfield API key: how to get one and send it
A Higgsfield API key is a key ID plus a secret made in Higgsfield Console, sent together in one Authorization: Key header from server code only.
- HMAC vs digital signature: what each proves for webhooks
An HMAC proves the sender holds a shared secret. A digital signature is made with a private key and checked with a public one, adding non-repudiation.
Written by Sume