Comfy-Org/ComfyUI · error · ValueError
SeedVR2Preprocess failed to pad video length to 4n+1; got {v
Error message
SeedVR2Preprocess failed to pad video length to 4n+1; got {videos.size(1)} frames. What it means
cut_videos pads the temporal dimension so the frame count satisfies t = 4n+1 (the SeedVR2 causal VAE layout). After concatenating the computed padding, it re-verifies the invariant; this error fires only if that post-condition somehow fails. In practice the arithmetic (padding by 4 - ((t-1) % 4)) always restores 4n+1, so this is a defensive assertion that should be unreachable.
Source
Thrown at comfy_extras/nodes_seedvr.py:89
padding = (0, pad_width, 0, pad_height)
return torch.nn.functional.pad(image, padding, mode='constant', value=0.0)
def cut_videos(videos):
t = videos.size(1)
if t < 1:
raise ValueError("SeedVR2Preprocess expected at least one frame.")
if t == 1:
return videos
if t <= 4:
padding = videos[:, -1:].repeat(1, 4 - t + 1, 1, 1, 1)
return torch.cat([videos, padding], dim=1)
if (t - 1) % 4 == 0:
return videos
padding = videos[:, -1:].repeat(1, 4 - ((t - 1) % 4), 1, 1, 1)
videos = torch.cat([videos, padding], dim=1)
if (videos.size(1) - 1) % 4 != 0:
raise ValueError(f"SeedVR2Preprocess failed to pad video length to 4n+1; got {videos.size(1)} frames.")
return videos
def _seedvr2_input_shorter_edge(images, node_name):
if images.dim() == 4:
return min(images.shape[1], images.shape[2])
if images.dim() == 5:
return min(images.shape[2], images.shape[3])
raise ValueError(
f"{node_name}: expected 4-D or 5-D IMAGE tensor, "
f"got shape {tuple(images.shape)}"
)
def _seedvr2_pad(images, upscaled_shorter_edge, node_name):
if upscaled_shorter_edge < 2:
raise ValueError(
f"{node_name}: input shorter edge must be at least 2 pixels; "
f"got {upscaled_shorter_edge}."View on GitHub (pinned to 1c6d8d45b3)
Solutions
- Treat occurrence as a bug: report the ComfyUI version, torch version, and input frame count to the maintainers.
- Verify torch is a standard release (pip check torch) and no custom tensor subclass or patching is active.
- As a workaround, pre-pad the video yourself to a 4n+1 frame count and bypass cut_videos.
Defensive patterns
Strategy: try-catch
Try / catch
try:
videos = cut_videos(videos)
except ValueError as e:
if 'failed to pad video length' in str(e):
raise RuntimeError('SeedVR2 padding invariant broken; report as a bug with torch version') from e
raise Prevention
- Keep torch at a standard ComfyUI-supported release.
- Avoid monkey-patching tensor ops in custom nodes.
- Report occurrences with the exact input frame count.
When it happens
Trigger: Requires (t - 1) % 4 != 0 after appending exactly 4 - ((t-1) % 4) copies of the last frame — mathematically impossible for integer t >= 5. Could only fire from a corrupted torch build or a mutation of videos between the cat and the check.
Common situations: Not seen in normal use; would indicate a non-standard torch environment or a monkey-patched tensor. Report as a bug against ComfyUI if it ever appears.
Related errors
- SeedVR2Preprocess expected at least one frame.
- SeedVR2TemporalChunk: frames_per_chunk must be a 4n+1 pixel-
- SeedVR2TemporalMerge: expected 5-D video latents (B, C, T, H
- SeedVR2TemporalMerge: chunk {i} shape {tuple(chunk.shape)} d
- SeedVR2TemporalMerge: chunk {i} has {chunk.shape[2]} latent
AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14).
Data as JSON: /api/errors/173ac887ff7f954f.
Report an issue: GitHub.