HunyuanVideo Get Closest Bucket Size
Matching your image to what the model was trained on
- image
- width
- height
Like most video and image models, HunyuanVideo wasn't trained on arbitrary resolutions - it was trained on a set of bucketed sizes at a few base resolutions. Feed it a width/height combination far outside those buckets and you can get worse composition or outright weird results, especially for image-to-video where the reference image's aspect ratio matters. This small utility node does one calculation: given your input image and a base size, it works out the closest matching bucket resolution and returns it as plain width/height integers.
It's a calculator, not a resizer - it doesn't touch your actual image. You take its width/height output and either feed them into HyVideoSampler's width/height inputs directly, or use them with a separate resize node upstream if your reference image doesn't already match.
The inputs that matter
image- the image whose aspect ratio you're matching to a bucket.base_size-360,540, or720(default 540). This is roughly the target's shorter-side resolution class; the tooltip describes it plainly as resizing to the closest original training bucket size. Pick based on how much detail/VRAM budget you want: 720 gives you a sharper starting point but costs more memory downstream; 360 is the cheap option if you're VRAM-constrained.
Outputs: width and height, both INT.
How to install it
Ships with the pack - no separate download.
- ComfyUI Manager - search ComfyUI-HunyuanVideoWrapper, install, restart.
- Manual -
cd ComfyUI/custom_nodes && git clone https://github.com/kijai/ComfyUI-HunyuanVideoWrapper, thenpip install -r ComfyUI-HunyuanVideoWrapper/requirements.txt, restart.
No model files needed - this is a pure math utility, nothing to download.
Common issues & troubleshooting
Connected it, but your image looks unchanged / nothing seems to happen. That's expected - this node only outputs numbers. If you also wanted the image itself resized to match, you need a separate image-resize node in your graph feeding from the same source, using these outputs as its target dimensions.
Output width/height look like an odd aspect ratio compared to your source image. The bucket sizing snaps to the nearest trained resolution, which won't exactly match every possible input aspect ratio - some rounding to the model's known buckets is expected and is the whole point of the node.
Not sure whether to use this at all. If you're feeding a reference image into HyVideoI2VEncode or HyVideoEncode and your source image is already close to a standard resolution the model likes (say, a clean 960x544 or similar), you probably don't need this. It's most useful when your source image comes from an arbitrary camera or crop and you want to avoid guessing at what resolution the sampler should target.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| base_size | COMBO | 540 | Resizes the input image to closest original training bucket size |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| width | INT | — |
| height | INT | — |