Comfy-Org/ComfyUI · error · ValueError

Second audio encoder output must be provided if two masks ar

Error message

Second audio encoder output must be provided if two masks are used.

What it means

The mirror-image guard of the two-speaker check: if both mask_1 and mask_2 are provided but there is no second audio encoder output, the masks have nothing to pair with, so the node raises before torch.cat([mask_1, mask_2]). Exactly one pair of (masks, audio streams) mismatched inputs is disallowed.

Source

Thrown at comfy_extras/nodes_wan.py:1522

    def execute(cls, mode: DCValues, model, model_patch, positive, negative, vae, width, height, length, audio_encoder_output_1, motion_frame_count,
                start_image=None, previous_frames=None, audio_scale=None, clip_vision_output=None, audio_encoder_output_2=None, mask_1=None, mask_2=None) -> io.NodeOutput:

        if previous_frames is not None and previous_frames.shape[0] < motion_frame_count:
            raise ValueError("Not enough previous frames provided.")

        if mode["mode"] == "two_speakers":
            audio_encoder_output_2 = mode["audio_encoder_output_2"]
            mask_1 = mode["mask_1"]
            mask_2 = mode["mask_2"]

        if audio_encoder_output_2 is not None:
            if mask_1 is None or mask_2 is None:
                raise ValueError("Masks must be provided if two audio encoder outputs are used.")

        ref_masks = None
        if mask_1 is not None and mask_2 is not None:
            if audio_encoder_output_2 is None:
                raise ValueError("Second audio encoder output must be provided if two masks are used.")
            ref_masks = torch.cat([mask_1, mask_2])

        latent = torch.zeros([1, 16, ((length - 1) // 4) + 1, height // 8, width // 8], device=comfy.model_management.intermediate_device())
        if start_image is not None:
            start_image = comfy.utils.common_upscale(start_image[:length].movedim(-1, 1), width, height, "bilinear", "center").movedim(1, -1)
            image = torch.ones((length, height, width, start_image.shape[-1]), device=start_image.device, dtype=start_image.dtype) * 0.5
            image[:start_image.shape[0]] = start_image

            concat_latent_image = vae.encode(image[:, :, :, :3])
            concat_mask = torch.ones((1, 1, latent.shape[2], concat_latent_image.shape[-2], concat_latent_image.shape[-1]), device=start_image.device, dtype=start_image.dtype)
            concat_mask[:, :, :((start_image.shape[0] - 1) // 4) + 1] = 0.0

            positive = node_helpers.conditioning_set_values(positive, {"concat_latent_image": concat_latent_image, "concat_mask": concat_mask})
            negative = node_helpers.conditioning_set_values(negative, {"concat_latent_image": concat_latent_image, "concat_mask": concat_mask})

        if clip_vision_output is not None:
            positive = node_helpers.conditioning_set_values(positive, {"clip_vision_output": clip_vision_output})
            negative = node_helpers.conditioning_set_values(negative, {"clip_vision_output": clip_vision_output})

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Connect the second audio encoder output when both masks are used
  2. Or disconnect mask_1/mask_2 for single-speaker generation
  3. Ensure mask inputs and audio inputs always come in pairs (2 masks <-> 2 audio streams)
Defensive patterns

Strategy: validation

Validate before calling

if mask_1 is not None or mask_2 is not None:
    assert audio_encoder_output_2 is not None, "two masks need a second audio stream"
    if mask_1 is None or mask_2 is None:
        raise ValueError("masks must come as a pair")

Prevention

When it happens

Trigger: Connecting mask_1 and mask_2 while audio_encoder_output_2 is None and the mode is not 'two_speakers' (the mode branch would have populated it); partially converted workflows where masks remain from a two-speaker setup but the second audio input was removed.

Common situations: Downgrading a two-speaker workflow to single speaker by deleting the second audio loader but leaving the masks wired; testing masks independently.

Related errors


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