Video Resolution
The node that figures out how many frames your video needs
- Width
- Height
- Frames
Video models in ComfyUI are fussy about their numbers. Want a 5-second clip at 16fps? That's 80 frames - but many video backends want the frame count aligned to a multiple of 4, and some want specific resolutions per aspect ratio, and nobody wants to compute length × fps plus alignment by hand for every test run. NNVideoResolution does the whole calculation and hands you three integers: width, height, and frames.
What it is
NNVideoResolution is the video sibling of the pack's NNImageResolution calculator. It takes a resolution, an aspect ratio, a duration, and a frame rate, and outputs Width, Height, and Frames - everything a video latent node or empty-video-latent node needs to be told. The README frames it as: "Calculates video dimensions and frame count based on resolution, aspect ratio, duration, and frame rate."
How it works
The dimensions come from the same resolution logic as the image calculator - you give it width/height, it reshapes or fills in the missing one to match the chosen aspect ratio (preserving total pixel count when both are given), rounds to divisible_by, and swaps for portrait if asked. The video-specific addition is the frame count:
frames = round_to(length × frame_rate, 4) + 1
That is: seconds times fps, rounded down to a multiple of 4, plus one. The extra frame is a real thing in video workflows - many generation loops count the first/last anchor frame or want one more frame than the math suggests for temporal alignment. It's baked in so you don't have to know about it. frame_rate is a dropdown of 16, 24, or 30 - the common video-model rates - and length is in seconds, default 5, up to 120.
The three results also print in the node's UI text, so you can see the numbers it chose before you wire them anywhere.
The inputs that matter
width/height- starting dimensions;heightdefaults to -1 (mirror width).aspect_ratio-auto,1:1,9:7,5:4,4:3,3:2,16:9,2:1,21:9.length- seconds, 0–120, default 5.frame_rate- 16, 24, or 30.divisible_by- default 2; bump to 8/16 for video-model alignment.portrait- portrait orientation toggle.
Outputs: Width (INT), Height (INT), Frames (INT). Wire them into your empty video latent or whichever node asks for dimensions and frame count.
When to reach for it
Whenever you're iterating on a video workflow and changing the clip length or aspect ratio - this is the node that makes "try 8 seconds at 24fps" a single dropdown change instead of a mental-arithmetic session plus a latent node edit. Because the width/height/frames logic is consistent, it also keeps you aligned: generate at the computed size, upscale or regrade against the same numbers, and you never drift out of the model's preferred multiples.
Installing
Part of bandifiu/ComfyUI-NN-custom-nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/bandifiu/ComfyUI-NN-custom-nodes
Restart ComfyUI (or Manager → "NN-custom-nodes"). Deps: torch, numpy, pillow - no models, no downloads. GPL-3.0, V3 backend API, no classic registration dicts.
The thing to remember: the +1 frame is already in there. If you've been hand-computing length × fps and wondering why the node's answer is one more than yours, that's deliberate, not a bug - and if you're feeding a backend that wants a different convention, the difference is a single frame you can adjust on the latent side. Also, frame_rate is locked to the three presets; if your model wants 12fps or 48fps you'll need to convert on your own.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 10240–8192 | — |
| height | INT | -1-1–8192 | — |
| aspect_ratio | COMBO | 9 options: auto, 1:1, 9:7, 5:4, 4:3, 3:2, +3 | |
| length | FLOAT | 5.00–120 | Length in seconds |
| frame_rate | COMBO | 3 options: 16, 24, 30 | |
| divisible_by | INT | 22–256 | — |
| portrait | BOOLEAN | false | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| Width | INT | — |
| Height | INT | — |
| Frames | INT | — |