calesthio/OpenMontage · error · ValueError

reference_video_durations must match the number of reference

Error message

reference_video_durations must match the number of reference videos

What it means

Raised when reference_video_durations is provided but its length differs from the number of video references. Durations are per-video hints used for validation and trimming, so they must be a parallel array to reference_video_urls.

Source

Thrown at tools/video/seedance_ark.py:788

            max_audios = 10 if variant == "2.5" else 3
            max_reference_seconds = 30 if variant == "2.5" else 15
            if len(image_refs) > max_images:
                raise ValueError(
                    f"reference_to_video accepts at most {max_images} reference images"
                )

            video_refs = list(inputs.get("reference_video_urls") or [])
            if inputs.get("reference_video_url"):
                video_refs.append(inputs["reference_video_url"])
            if len(video_refs) > max_videos:
                raise ValueError(
                    f"reference_to_video accepts at most {max_videos} reference videos"
                )
            self._validate_remote_refs(video_refs, "reference video")
            video_durations = list(inputs.get("reference_video_durations") or [])
            if video_durations:
                if len(video_durations) != len(video_refs):
                    raise ValueError(
                        "reference_video_durations must match the number of "
                        "reference videos"
                    )
                if any(
                    float(value) < 2 or float(value) > max_reference_seconds
                    for value in video_durations
                ):
                    raise ValueError(
                        f"each reference video duration must be 2 to {max_reference_seconds} seconds"
                    )
                if (
                    sum(float(value) for value in video_durations)
                    > max_reference_seconds
                ):
                    raise ValueError(
                        "all reference videos together must be at most "
                        f"{max_reference_seconds} seconds"
                    )

View on GitHub (pinned to 95e1c3d0ab)

Solutions

  1. Regenerate reference_video_durations so it has exactly one entry per video ref, in the same order
  2. Omit reference_video_durations entirely if you cannot measure clip lengths

Example fix

# before
inputs = {"reference_video_urls": [v1, v2, v3],
          "reference_video_durations": [5, 5]}

# after
inputs = {"reference_video_urls": [v1, v2, v3],
          "reference_video_durations": [5, 5, 5]}
Defensive patterns

Strategy: validation

Validate before calling

durs = list(inputs.get("reference_video_durations") or [])
if durs and len(durs) != len(video_refs):
    inputs["reference_video_durations"] = []  # or rebuild per-clip via ffprobe
    # better: probe each ref
    # inputs["reference_video_durations"] = [probe_duration(u) for u in video_refs]

Type guard

def durations_match(durations: list, refs: list) -> bool:
    return not durations or len(durations) == len(refs)

Prevention

When it happens

Trigger: len(reference_video_durations) != len(reference_video_urls) (counting the singular reference_video_url) while the durations list is non-empty.

Common situations: Adding or removing a video ref without updating the durations array; reusing a durations list across different requests; including a duration for the singular reference_video_url but forgetting it in the count.

Related errors


AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15). Data as JSON: /api/errors/b6ed035247827f5d. Report an issue: GitHub.