Comfy-Org/ComfyUI · error · ValueError

Provide either a background image or a background video, not

Error message

Provide either a background image or a background video, not both.

What it means

Bria's video replace-background endpoint takes exactly one background source. The node models this as two optional inputs (background_image, background_video) and enforces XOR: providing both, or neither, raises this error before any upload.

Source

Thrown at comfy_api_nodes/nodes_bria.py:969

                IO.Hidden.api_key_comfy_org,
                IO.Hidden.unique_id,
            ],
            is_api_node=True,
            price_badge=IO.PriceBadge(
                expr="""{"type":"usd","usd":0.05,"format":{"suffix":"/second"}}""",
            ),
        )

    @classmethod
    async def execute(
        cls,
        video: Input.Video,
        seed: int,
        background_image: Input.Image | None = None,
        background_video: Input.Video | None = None,
    ) -> IO.NodeOutput:
        if (background_image is None) == (background_video is None):
            raise ValueError("Provide either a background image or a background video, not both.")
        validate_video_duration(video, max_duration=60.0)
        if background_video is not None:
            validate_video_duration(background_video, max_duration=60.0)
            background_url = await upload_video_to_comfyapi(cls, background_video, wait_label="Uploading background")
        else:
            # Bria's replace_background 500s on RGBA, so drop the alpha channel before upload.
            background_url = await upload_image_to_comfyapi(
                cls, background_image[:, :, :, :3], wait_label="Uploading background"
            )
        response = await sync_op(
            cls,
            ApiEndpoint(path="/proxy/bria/v2/video/edit/replace_background", method="POST"),
            data=BriaVideoReplaceBackgroundRequest(
                video=await upload_video_to_comfyapi(cls, video),
                background_url=background_url,
                output_container_and_codec="mp4_h264",
                seed=seed,
            ),

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Connect exactly one of background_image or background_video.
  2. If you want the original (no replacement), this is the wrong node - remove it.
  3. Note: RGBA background images have alpha dropped before upload because Bria 500s on RGBA.

Example fix

// before
background_image: img, background_video: vid
// after
background_image: img, background_video: null
Defensive patterns

Strategy: validation

Validate before calling

if (background_image is None) == (background_video is None):
    raise UserError('Connect exactly one of background_image / background_video.')

Prevention

When it happens

Trigger: (background_image is None) == (background_video is None) evaluates true - both connected, or both left empty.

Common situations: User wires both inputs 'to be safe'; or copies the node into a workflow and connects neither, assuming a transparent/default background exists.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/dde9e2c0f0942623. Report an issue: GitHub.