Publish Seedance 2.5 draft mode and video updates

- Add the 样片模式 flow: 480p draft generation, a linkable draft task ID, and pre-flight verification before the 1080p final request.

- Allow reference images and audio in video edit/extend requests, matching the provider's 2.5 contract.

- Move 主模型 and 样片模式 ahead of 生成模式, default 主模型 to seedance 2.5, and migrate saved widget values.

- Refresh the video panel, asset API response logs, and LLM node handling; cover the new behavior with offline tests.
This commit is contained in:
Jony
2026-10-21 20:13:55 +08:00
parent 532d4a9541
commit ff1cf830fa
27 changed files with 1810 additions and 341 deletions
+56 -14
View File
@@ -13,12 +13,14 @@ SEEDANCE_MODEL_OPTIONS = [
"seedance-2.5",
]
SEEDANCE_ROUTE_OPTIONS = ["domestic", "overseas_hc"]
SEEDANCE_ASSET_CREATION_MODE_OPTIONS = ["auto", "manual"]
SEEDANCE_ASSET_CREATION_MODE_OPTIONS = ["direct", "auto", "manual"]
VIDEO_GENERATION_MODE_OPTIONS = [
"text",
"first_frame",
"first_last_frame",
"multimodal",
"edit",
"extend",
]
VIDEO_RESOLUTION_OPTIONS = ["480p", "720p", "1080p", "4k"]
VIDEO_ASPECT_RATIO_OPTIONS = ["auto", "16:9", "9:16", "4:3", "3:4", "1:1", "21:9"]
@@ -26,8 +28,10 @@ VIDEO_DURATION_OPTIONS = ["auto", *[str(value) for value in range(4, 31)]]
MAX_VIDEO_PROMPT_CHARS = 20_000
SEEDANCE_REFERENCE_IMAGE_MAX_BYTES = 30 * 1024 * 1024
SEEDANCE_REFERENCE_VIDEO_MAX_BYTES = 512 * 1024 * 1024
SEEDANCE_REFERENCE_AUDIO_MAX_BYTES = 100 * 1024 * 1024
SEEDANCE_REFERENCE_VIDEO_MAX_BYTES = 200 * 1024 * 1024
SEEDANCE_REFERENCE_AUDIO_MAX_BYTES = 15 * 1024 * 1024
SEEDANCE_REFERENCE_AUDIO_EXTENSIONS = (".wav", ".mp3")
SEEDANCE_REFERENCE_MIN_SECONDS = 2
SEEDANCE_REFERENCE_MIN_DIMENSION = 300
SEEDANCE_REFERENCE_MAX_DIMENSION = 6000
SEEDANCE_REFERENCE_MIN_ASPECT_RATIO = 0.4
@@ -54,6 +58,7 @@ SEEDANCE_CAPABILITIES = {
"videos": 3,
"audios": 3,
"resolutions": ["480p", "720p", "1080p", "4k"],
"reference_seconds": 15,
},
"seedance-2.0-fast": {
"duration_min": 4,
@@ -62,6 +67,7 @@ SEEDANCE_CAPABILITIES = {
"videos": 3,
"audios": 3,
"resolutions": ["480p", "720p"],
"reference_seconds": 15,
},
"seedance-2.0-mini": {
"duration_min": 4,
@@ -70,6 +76,7 @@ SEEDANCE_CAPABILITIES = {
"videos": 3,
"audios": 3,
"resolutions": ["480p", "720p"],
"reference_seconds": 15,
},
"seedance-2.5": {
"duration_min": 4,
@@ -77,7 +84,8 @@ SEEDANCE_CAPABILITIES = {
"images": 30,
"videos": 10,
"audios": 10,
"resolutions": ["480p", "720p", "1080p", "4k"],
"resolutions": ["480p", "720p", "1080p"],
"reference_seconds": 30,
},
}
@@ -111,7 +119,7 @@ def normalize_seedance_parameters(payload: dict[str, Any]) -> dict[str, Any]:
mode = str(payload.get("generation_mode") or "text").strip()
if mode not in VIDEO_GENERATION_MODE_OPTIONS:
raise ValueError(f"不支持的视频生成模式:{mode}")
asset_creation_mode = str(payload.get("asset_creation_mode") or "auto").strip()
asset_creation_mode = str(payload.get("asset_creation_mode") or "direct").strip()
if asset_creation_mode not in SEEDANCE_ASSET_CREATION_MODE_OPTIONS:
raise ValueError(f"不支持的素材创建模式:{asset_creation_mode}")
@@ -133,23 +141,27 @@ def normalize_seedance_parameters(payload: dict[str, Any]) -> dict[str, Any]:
raw_duration = str(payload.get("duration") or "5").strip().lower()
if raw_duration == "auto":
duration = 5
# -1 是上游约定的自动时长,必须原样透传。
duration = -1
else:
try:
duration = int(raw_duration.removesuffix("秒"))
except ValueError:
raise ValueError(f"无效的视频时长:{raw_duration}") from None
if not capabilities["duration_min"] <= duration <= capabilities["duration_max"]:
if duration != -1 and not capabilities["duration_min"] <= duration <= capabilities["duration_max"]:
raise ValueError(
f"{model} 的时长仅支持 {capabilities['duration_min']}-{capabilities['duration_max']} 秒"
)
try:
seed = int(payload.get("seed") or 0)
except (TypeError, ValueError):
raise ValueError("seed 必须是非负整数") from None
if not 0 <= seed <= 0xFFFFFFFFFFFFFFFF:
raise ValueError("seed 必须是 0 到 18446744073709551615 之间的整数")
# 文档约束:2.5 的编辑/延长只用 adaptive,编辑必须显式 -1,首帧类也跟随图片比例
if mode in {"edit", "extend"}:
if model != "seedance-2.5":
raise ValueError("视频编辑和视频延长仅支持 Seedance 2.5")
aspect_ratio = "auto"
if mode == "edit":
duration = -1
if model == "seedance-2.5" and mode in {"first_frame", "first_last_frame"}:
aspect_ratio = "auto"
filename_prefix = str(payload.get("filename_prefix") or "o1key_video").strip()
if not filename_prefix:
@@ -170,7 +182,6 @@ def normalize_seedance_parameters(payload: dict[str, Any]) -> dict[str, Any]:
"duration": duration,
"generate_audio": _as_bool(payload.get("generate_audio")),
"return_last_frame": _as_bool(payload.get("return_last_frame")),
"seed": seed,
"filename_prefix": filename_prefix,
"save_location": str(payload.get("save_location") or "").strip(),
"capabilities": capabilities,
@@ -200,6 +211,31 @@ def validate_seedance_media_counts(
raise ValueError(f"{label} 最多支持 {limit} 个{media_label},当前输入 {count} 个")
def validate_seedance_reference_durations(
model: str,
video_seconds: list[float],
audio_seconds: list[float],
*,
model_label: str | None = None,
) -> None:
"""Apply the shared per-item and total reference-time limits."""
if model not in SEEDANCE_CAPABILITIES:
raise ValueError(f"不支持的 Seedance 模型:{model}")
limit = SEEDANCE_CAPABILITIES[model]["reference_seconds"]
label = model_label or model
for media_label, durations in (("参考视频", video_seconds), ("参考音频", audio_seconds)):
for index, seconds in enumerate(durations, start=1):
if not SEEDANCE_REFERENCE_MIN_SECONDS <= seconds <= limit:
raise ValueError(
f"{label} 的{media_label}{index}时长必须在 "
f"{SEEDANCE_REFERENCE_MIN_SECONDS}~{limit} 秒,当前为 {seconds:.1f} 秒"
)
total = sum(durations)
if total > limit:
raise ValueError(f"{label} 的{media_label}总时长不能超过 {limit} 秒,当前为 {total:.1f} 秒")
def validate_seedance_reference_dimensions(
width: int,
height: int,
@@ -268,8 +304,11 @@ def public_video_capabilities() -> dict[str, Any]:
{"value": "first_frame", "label": "首帧图生视频"},
{"value": "first_last_frame", "label": "首尾帧生视频"},
{"value": "multimodal", "label": "多模态参考生视频"},
{"value": "edit", "label": "视频编辑"},
{"value": "extend", "label": "视频延长"},
],
"asset_creation_modes": [
{"value": "direct", "label": "直接上传"},
{"value": "auto", "label": "自动创建"},
{"value": "manual", "label": "手动"},
],
@@ -286,7 +325,9 @@ __all__ = [
"SEEDANCE_MODEL_MATRIX",
"SEEDANCE_MODEL_OPTIONS",
"SEEDANCE_REFERENCE_AUDIO_MAX_BYTES",
"SEEDANCE_REFERENCE_AUDIO_EXTENSIONS",
"SEEDANCE_REFERENCE_IMAGE_MAX_BYTES",
"SEEDANCE_REFERENCE_MIN_SECONDS",
"SEEDANCE_REFERENCE_MAX_ASPECT_RATIO",
"SEEDANCE_REFERENCE_MAX_DIMENSION",
"SEEDANCE_REFERENCE_MIN_ASPECT_RATIO",
@@ -305,4 +346,5 @@ __all__ = [
"resolve_seedance_model",
"validate_seedance_media_counts",
"validate_seedance_reference_dimensions",
"validate_seedance_reference_durations",
]