height not divisible by 2 means libx264 got an odd frame size, such as 720x405 from scale=720:-1 on 1080p video. Use scale=720:-2 for an even 720x406, locally or on ReelSDK at $0.02 per compute minute.

height not divisible by 2 (720x405)

We reproduced it with ffmpeg 8.1 and 7.1: x264 checked the frame size before encoding, found an odd height, and ffmpeg exited with code 187. ReelSDK runs your args as written, so the -1 version fails there too, with HTTP 422 and no charge.

ErrorsUpdated

ffmpeg 8.1, scale=720:-1 on a 1920x1080 video, exit code 187
[libx264 @ 0x56057615a4c0] height not divisible by 2 (720x405)
[vost#0:0/libx264 @ 0x5605761591c0] [enc:libx264 @ 0x5605760eea80] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[vf#0:0 @ 0x56057615ae00] Error sending frames to consumers: Generic error in an external library
[vf#0:0 @ 0x56057615ae00] Task finished with error code: -542398533 (Generic error in an external library)
[vf#0:0 @ 0x56057615ae00] Terminating thread with return code -542398533 (Generic error in an external library)
[vost#0:0/libx264 @ 0x5605761591c0] [enc:libx264 @ 0x5605760eea80] Could not open encoder before EOF
[vost#0:0/libx264 @ 0x5605761591c0] Task finished with error code: -22 (Invalid argument)
[vost#0:0/libx264 @ 0x5605761591c0] Terminating thread with return code -22 (Invalid argument)
[out#0/mp4 @ 0x560576160480] Nothing was written into output file, because at least one of its streams received no packets.
frame=    0 fps=0.0 q=0.0 Lsize=       0KiB time=N/A bitrate=N/A speed=N/A elapsed=0:00:00.08
[aac @ 0x56057638d1c0] Qavg: 273.926
Conversion failed!

Source: x264 encoder.c, checked November 2026.

Where it shows up

x264 rejects the size before the first frame

You resize with -1 for one side, crop, or feed in a source whose width or height is odd, and encode with -c:v libx264. We ran ffmpeg -i in.mp4 -vf scale=720:-1 -c:v libx264 out.mp4 on a 1920x1080 video: 1080 x 720 / 1920 = 405, so the frame came out 720x405.

x264 prints height not divisible by 2 (720x405), ffmpeg cannot open the encoder, writes nothing and ends with Conversion failed!. ffmpeg 8.1 and 7.1 exit with code 187; ffmpeg 6.0 and 4.4 exit with code 1. An odd width gives the twin message: scale=-1:720 on a 1080x1920 vertical video printed width not divisible by 2 (405x720).

Why it happens

4:2:0 video stores color for 2x2 blocks of pixels

H.264 in an .mp4 is nearly always 4:2:0 (yuv420p): one color sample covers a 2x2 block of pixels, so a frame needs whole blocks. x264's own source checks this when the encoder opens: for 4:2:0 the width and the height must be divisible by 2, and the height by 4 for interlaced video. 4:2:2 only needs an even width, and 4:4:4 has no rule.

-1 in the scale filter keeps the aspect ratio but does not round, so most target sizes land on an odd number. -2 keeps the ratio and then makes the computed side divisible by 2, which is how the ffmpeg filter docs define -n.

Causes and fixes

What gives an odd size, and the fix

What gives an odd size, and the fix
What you ranWhat the encoder gotFix
scale=720:-1 on 1920x1080720x405: height not divisible by 2scale=720:-2 gives 720x406
scale=-1:720 on 1080x1920405x720: width not divisible by 2scale=-2:720 gives 406x720
A 1279x719 sourcewidth not divisible by 2 (1279x719)trunc(iw/2)*2 gives 1278x718, a ceil pad gives 1280x720
crop=1279:719No error: crop rounds 4:2:0 down to 1278x718Nothing to fix, unless you set exact=1
-c:v libx265 or libsvtav1Their own odd-height errors, exit 183 and 234The same even sizes

Source: x264 encoder.c, checked November 2026.

The local fix

Round the size to an even number

Swap -1 for -2. On the same 1920x1080 input, scale=720:-2 gave 720x406 and encoded cleanly. For a fixed height, use scale=-2:720, which turned a 1080x1920 video into 406x720.

If the source is already odd, round both sides. scale=trunc(iw/2)*2:trunc(ih/2)*2 turned a 1279x719 file into 1278x718, and pad=ceil(iw/2)*2:ceil(ih/2)*2 grew it to 1280x720 instead; both encoded with exit code 0.

fixed-width.sh
ffmpeg -i in.mp4 -vf scale=720:-2 -c:v libx264 -crf 23 -c:a aac out.mp4
odd-source.sh
# drop the odd row and column
ffmpeg -i in.mp4 -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" -c:v libx264 -c:a aac out.mp4

# or add one
ffmpeg -i in.mp4 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -c:v libx264 -c:a aac out.mp4
check-size.sh
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=p=0 in.mp4
# 1920,1080

Skip the binary

Or send the same args to the API

POST /v1/ffmpeg runs your args on ffmpeg 8.1 with libx264 built in, on a fresh machine per job. The scale=720:-2 command wrote a 720x406 out.mp4 about 5 seconds after the request. Compute is $0.02 per minute, billed per second, so that job cost under a fifth of a cent.

The API runs your args as they are, so it does not round for you: the scale=720:-1 version failed with HTTP 422 and FFMPEG_FAILED, and failed jobs are not billed.

convert.mjsTry it
const res = await fetch("https://api.reelsdk.com/v1/ffmpeg?wait=60", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.REELSDK_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "inputs": {
      "in.mp4": "https://api.reelsdk.com/f/lib/demo/landscape.mp4"
    },
    "args": [
      "-i", "in.mp4", "-vf", "scale=720:-2", "-c:v", "libx264", "-crf", "23",
      "-c:a", "aac", "-movflags", "+faststart", "out.mp4"
    ],
    "outputs": ["out.mp4"]
  }),
});
const { job } = await res.json();
The same command with scale=720:-2 on the API: an even 720x406.Input: 1920x1080 input

Other encoders on the same 720x405 frame

We sent the same 720x405 frame to other encoders on ffmpeg 7.1. libx265 stopped with Picture height must be an integer multiple of the specified chroma subsampling (exit 183) and libsvtav1 with Source Height must be even for YUV_420 colorspace (exit 234). libvpx-vp9, libaom-av1 and mpeg4 encoded it as is.

libopenh264, the H.264 encoder in LGPL builds, did not fail on ffmpeg 8.1: it wrote a 720x404 file, one row shorter than you asked for. Round the size yourself and every encoder gets the same frame.

Keeping an odd size

x264 has no size rule for 4:4:4, so -pix_fmt yuv444p encoded the 720x405 frame as H.264 High 4:4:4 Predictive. Use that only when you control the player; for files people download or post, round to an even size.

fluent-ffmpeg already rounds for you when you let it compute a side: .size('720x?') in fluent-ffmpeg becomes scale=w=720:h=trunc(ow/a/2)*2. Writing the filter yourself with -1 is what brings the error back.

FAQ

Questions, answered

Why does scale=720:-1 give an odd height?

-1 keeps the aspect ratio exactly and does not round. A 1920x1080 video at width 720 works out to 1080 x 720 / 1920 = 405, an odd number, and x264 needs an even height for 4:2:0 video.

What is the difference between -1 and -2 in scale?

Both keep the aspect ratio. -2 then makes the computed side divisible by 2, so libx264 always gets an even size: scale=720:-2 gave 720x406 on the same video.

Why did crop=1279:719 work when scale did not?

The crop filter rounds 4:2:0 video down to whole 2x2 blocks unless you set exact=1, so it produced 1278x718. The scale filter does what you ask, odd sizes included.

Does the API round the size for me?

No. POST /v1/ffmpeg runs your args as they are on ffmpeg 8.1, so the scale=720:-1 version fails there too, with HTTP 422 and FFMPEG_FAILED. Failed jobs are not billed.

Ready to build?

Ship video from your app today

Your first $0.50 is free, and one key covers every endpoint.

Moonlit lake with a lit cabin under the mountains