{"record":{"id":"55ceb41d5c5bc48c","repo":"Comfy-Org/ComfyUI","slug":"seedvr2preprocess-expected-at-least-one-frame","errorCode":null,"errorMessage":"SeedVR2Preprocess expected at least one frame.","messagePattern":"SeedVR2Preprocess expected at least one frame\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_seedvr.py","lineNumber":78,"sourceCode":"\n\ndef div_pad(image, factor):\n    height_factor, width_factor = factor\n    height, width = image.shape[-2:]\n\n    pad_height = (height_factor - (height % height_factor)) % height_factor\n    pad_width = (width_factor - (width % width_factor)) % width_factor\n\n    if pad_height == 0 and pad_width == 0:\n        return image\n\n    padding = (0, pad_width, 0, pad_height)\n    return torch.nn.functional.pad(image, padding, mode='constant', value=0.0)\n\ndef cut_videos(videos):\n    t = videos.size(1)\n    if t < 1:\n        raise ValueError(\"SeedVR2Preprocess expected at least one frame.\")\n    if t == 1:\n        return videos\n    if t <= 4:\n        padding = videos[:, -1:].repeat(1, 4 - t + 1, 1, 1, 1)\n        return torch.cat([videos, padding], dim=1)\n    if (t - 1) % 4 == 0:\n        return videos\n    padding = videos[:, -1:].repeat(1, 4 - ((t - 1) % 4), 1, 1, 1)\n    videos = torch.cat([videos, padding], dim=1)\n    if (videos.size(1) - 1) % 4 != 0:\n        raise ValueError(f\"SeedVR2Preprocess failed to pad video length to 4n+1; got {videos.size(1)} frames.\")\n    return videos\n\ndef _seedvr2_input_shorter_edge(images, node_name):\n    if images.dim() == 4:\n        return min(images.shape[1], images.shape[2])\n    if images.dim() == 5:\n        return min(images.shape[2], images.shape[3])","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_seedvr.py#L60-L96","documentation":"Raised by cut_videos in the SeedVR2 preprocessing path when the input video tensor has zero frames along the temporal dimension (t < 1). SeedVR2 requires at least one frame to build a 4n+1 temporal layout, so an empty sequence is rejected before padding. This is a shape-contract error, not a runtime environment problem.","triggerScenarios":"Passing an IMAGE tensor whose frame dimension (size(1) after the batchunsqueeze, i.e. videos.size(1) < 1) is empty. Typically an empty batch of frames from an upstream node (e.g. LoadVideo with a zero-length range, or a batch node that produced 0 frames) reaching SeedVR2Preprocess/cut_videos.","commonSituations":"Video loader configured with an empty frame range or start >= end; a downstream node slicing frames out of range ([10:10]) producing a 0-frame tensor; a workflow wired to an empty image list.","solutions":["Check the frame count of the tensor feeding the SeedVR2 node before it runs: images.shape[0] (for a 4-D frame stack) must be >= 1.","Fix the upstream video loader / frame-selection node so it outputs at least one frame (start frame < end frame).","If frames are selected dynamically, guard with: n = images.shape[0]; sel = images[max(0, min(start, n-1)):max(start+1, min(end, n))] so at least one frame survives."],"exampleFix":"# before\nframes = video[:, start:end]  # start == end -> 0 frames -> ValueError\n\n# after\nif end <= start:\n    raise ValueError(\"frame range is empty: end must be > start\")\nframes = video[:, start:end]","handlingStrategy":"validation","validationCode":"def has_frames(image):\n    # 4-D (N,H,W,C) or 5-D (B,N,H,W,C) Comfy IMAGE\n    return image.dim() in (4, 5) and image.shape[-4] >= 1","typeGuard":"def is_nonempty_video_image(t) -> bool:\n    return t.dim() in (4, 5) and t.shape[-4] >= 1 and t.shape[-1] in (1, 3, 4)","tryCatchPattern":null,"preventionTips":["Validate frame ranges (start < end) in loader/slicer nodes before slicing.","Add a debug print of images.shape before SeedVR2 nodes while building workflows.","Treat 0-frame tensors as upstream bugs; never construct empty image batches."],"tags":["seedvr","video","tensor-shape","validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}