XB-BOX - 🎨 Bernini 条件注入(VAE分块)
Feed source video and reference images into Bernini without OOMing
- positive
- negative
- vae
- source_video
- reference_video
- reference_image_0
- reference_image_1
- reference_image_2
- reference_image_3
- reference_image_4
- reference_image_5
- reference_image_6
- reference_image_7
- positive
- negative
- latent
Bernini is ByteDance's Wan-derived video editing model, and the thing that makes it work is context latents - the source video you're editing and up to eight reference images get VAE-encoded and injected into the conditioning so the model can actually see what it's editing. In stock ComfyUI you'd wire up a pile of encode steps and hope your VRAM survives. XB_BerniniConditioning wraps the whole job into one node: it builds the empty latent, encodes every context input you give it, and returns ready-made positive/negative conditioning plus the latent. With a tiled-VAE option to keep the memory bill sane.
It's categorized under XB_ToolBox/Wan, and it exists because Bernini is heavy - the KB's own panel notes that editing effectively doubles compute (the source video is part of the model input), and VRAM is the recurring complaint. The node's VAE tiling is aimed straight at that.
How it works
The node does three things in go():
- Builds the output latent: a zero tensor of shape
[batch, 16, ((length-1)//4)+1, height//8, width//8]- the standard Wan-style latent for your chosen width/height/length/batch. - Encodes context inputs: any of
source_video,reference_video, or the eightreference_image_0…7slots that are connected get resized (long edge toref_max_size, default 848) and VAE-encoded via a tiled encoder (vae_tile_size, default 256) so a large frame doesn't blow VRAM. - Injects: the encoded context is stored under
context_latentson both positive and negative conditioning, then positive/negative/latentare returned together.
So one node does what the stock Bernini workflow scatters across a half-dozen encode + set-values steps, and the tiling is the memory knob.
The inputs that matter
- positive / negative - your text conditioning (from a CLIP/Flux encode step).
- vae - the Wan VAE.
- width / height / length / batch_size - output latent geometry. Length is in frames (default 81, the classic Wan native length); note it's the output length, independent of your source video's frame count.
- source_video - the clip you're editing (for v2v). Optional; leave unconnected for pure text/image-to-video.
- reference_image_0…7 - up to eight reference images (for multi-ref character consistency). Each is treated as an individual context frame.
- ref_max_size - long-edge resize cap for references; keeps big images from inflating the context.
- vae_tile_size - the VRAM lever. Lower it if encoding OOMs; raise it for speed if you have headroom.
- scale_method - resize algorithm for inputs (
areadefault).
Outputs: positive, negative (CONDITIONING with context latents baked in), latent (the empty latent to sample from).
Installing
Comes with XB_ToolBox - ComfyUI Manager → XB_ToolBox, or
cd ComfyUI/custom_nodes
git clone https://github.com/WJLUOXIAO/XB_ToolBox.git
restart. It needs a working Wan VAE and the Bernini model loaded elsewhere in the graph (this node doesn't load any model itself).
Common issues
- OOM during encode - drop
vae_tile_size(256 → 192 → 128). Tiling is the whole point here; if you still OOM, reduceref_max_sizeor feed fewer references. - Output latent and video don't match -
source_videois truncated tolengthframes but not otherwise downsampled temporally; keep your source ≤ the length you set, or you'll silently get only the first N frames as context. - No context, no edit - if you forget to connect
source_video, you get a text-to-video latent with context-latent conditioning that references nothing. For edits, the source clip is the whole show. - Frame-count rule - keep
lengthin the4N+1family (81, 121…) that Wan expects, or the sampler may reject it.
This is the node that makes a Bernini workflow actually fits on a consumer card. It won't make Bernini cheap - nothing does - but it removes the encode-side explosion that used to kill runs before the first denoising step.
Inputs (20)
| Name | Type | Default | Description |
|---|---|---|---|
| positive | CONDITIONING | — | |
| negative | CONDITIONING | — | |
| vae | VAE | — | |
| width | INT | 83216–8192 | — |
| height | INT | 48016–8192 | — |
| length | INT | 811–8192 | — |
| batch_size | INT | 11–4096 | — |
| source_videoopt | IMAGE | — | |
| reference_videoopt | IMAGE | — | |
| reference_image_0opt | IMAGE | — | |
| reference_image_1opt | IMAGE | — | |
| reference_image_2opt | IMAGE | — | |
| reference_image_3opt | IMAGE | — | |
| reference_image_4opt | IMAGE | — | |
| reference_image_5opt | IMAGE | — | |
| reference_image_6opt | IMAGE | — | |
| reference_image_7opt | IMAGE | — | |
| ref_max_sizeopt | INT | 84816–8192 | — |
| vae_tile_sizeopt | INT | 25664–3840 | — |
| scale_methodopt | COMBO | area | 5 options: lanczos, bilinear, bicubic, nearest-exact, area |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| positive | CONDITIONING | — |
| negative | CONDITIONING | — |
| latent | LATENT | — |