ATH-MaaS/Pixelle-Video · error · ValueError
Invalid DashScope media combination: {'+'.join(sorted(media_
Error message
Invalid DashScope media combination: {'+'.join(sorted(media_types))}. Allowed: first_frame, first_frame+driving_audio, first_frame+last_frame, first_frame+last_frame+driving_audio, first_clip, first_clip+last_frame. What it means
_validate_media_combination checks that the set of media inputs passed to a DashScope wan2.7+ video generation is one of the whitelisted combinations. Any set of media types not exactly matching an allowed combination raises ValueError before the API call is made.
Source
Thrown at pixelle_video/services/api_services/video_dashscope.py:556
for ref_video_path in reference_video_paths or []:
if ref_video_path:
media.append({"type": "reference_video", "url": self._to_media_url(ref_video_path)})
return media
def _validate_media_combination(self, media: list[dict[str, str]]) -> None:
"""Validate combinations documented by DashScope wan2.7 i2v."""
media_types = {item["type"] for item in media}
allowed = [
{"first_frame"},
{"first_frame", "driving_audio"},
{"first_frame", "last_frame"},
{"first_frame", "last_frame", "driving_audio"},
{"first_clip"},
{"first_clip", "last_frame"},
]
if media_types not in allowed:
raise ValueError(
"Invalid DashScope media combination: "
f"{'+'.join(sorted(media_types))}. "
"Allowed: first_frame, first_frame+driving_audio, first_frame+last_frame, "
"first_frame+last_frame+driving_audio, first_clip, first_clip+last_frame."
)
def _to_media_url(self, path_or_url: str) -> str:
"""Convert a local path to file:// while preserving URL/data/OSS inputs."""
if path_or_url.startswith(("http://", "https://", "file://", "oss://", "data:")):
return path_or_url
return f"file://{os.path.abspath(path_or_url)}"
if __name__ == "__main__":
import sys
import time
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from config import ConfigView on GitHub (pinned to 848b054e4f)
Solutions
- Change the media inputs to one of the allowed combos: first_frame; first_frame+driving_audio; first_frame+last_frame; first_frame+last_frame+driving_audio; first_clip; first_clip+last_frame.
- If you only have an end frame, add a first_frame or switch to first_clip.
- Move driving_audio off a clip-only call — audio is only accepted with first_frame inputs.
- Fix typos/keys in the media dict; the error prints the offending combination as '+'.join(sorted(media_types)) to compare directly.
Example fix
# before
media = {"last_frame": end_image_url}
self._validate_media_combination(media) # ValueError
# after
media = {"first_frame": start_image_url, "last_frame": end_image_url}
self._validate_media_combination(media) # OK Defensive patterns
Strategy: validation
Validate before calling
ALLOWED = [
{"first_frame"}, {"first_frame", "driving_audio"},
{"first_frame", "last_frame"},
{"first_frame", "last_frame", "driving_audio"},
{"first_clip"}, {"first_clip", "last_frame"},
]
media_types = set(media.keys())
if media_types not in ALLOWED:
raise ValueError(f"不支持的媒体组合: {sorted(media_types)}") Type guard
def is_valid_media_combo(media: dict) -> bool:
allowed = [
{"first_frame"}, {"first_frame", "driving_audio"},
{"first_frame", "last_frame"},
{"first_frame", "last_frame", "driving_audio"},
{"first_clip"}, {"first_clip", "last_frame"},
]
return set(media.keys()) in allowed Try / catch
try:
url = client.generate_video(media=media, ...)
except ValueError as e:
if "Invalid DashScope media combination" in str(e):
media = {"first_frame": media.get("first_frame") or media.get("last_frame")}
url = client.generate_video(media=media, ...) Prevention
- Build media dicts from a fixed helper that only emits allowed combinations
- Never send driving_audio with first_clip inputs
- Provide first_frame whenever you provide last_frame
- Unit-test media combination builders against the whitelist
When it happens
Trigger: Calling generate_video with, e.g., only {'last_frame'} (no first_frame), {'first_clip','driving_audio'} (audio without clips' frames), {'first_frame','first_clip'} together, or {'driving_audio'} alone — the media set built by the caller doesn't match any allowed set (video_dashscope.py:552-558).
Common situations: Passing last_frame without first_frame, supplying driving_audio to an image-only workflow, accidentally including both an image and a video clip, or a refactored caller building the media dict with a typo in the media type key ('firstframe', 'audio').
Related errors
- DashScope reference-to-video models require at least one ref
- DashScope video edit models require video input and may use
- DashScope legacy video models require image_path.
- 无法解析 base64 图片: {e}
- Videos list cannot be empty
AI-assisted analysis of ATH-MaaS/Pixelle-Video@848b054e4f (2026-08-30).
Data as JSON: /api/errors/75574c2e13866846.
Report an issue: GitHub.