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:
@@ -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",
|
||||
]
|
||||
|
||||
+133
-33
@@ -23,6 +23,7 @@ from .config import get_base_url_by_route
|
||||
from .http_error import format_o1key_video_error
|
||||
from .o1key_image_save import normalize_save_location
|
||||
from .o1key_video_catalog import (
|
||||
SEEDANCE_REFERENCE_AUDIO_EXTENSIONS,
|
||||
SEEDANCE_REFERENCE_AUDIO_MAX_BYTES,
|
||||
SEEDANCE_REFERENCE_IMAGE_MAX_BYTES,
|
||||
SEEDANCE_REFERENCE_VIDEO_MAX_BYTES,
|
||||
@@ -30,6 +31,7 @@ from .o1key_video_catalog import (
|
||||
public_video_capabilities,
|
||||
validate_seedance_media_counts,
|
||||
validate_seedance_reference_dimensions,
|
||||
validate_seedance_reference_durations,
|
||||
)
|
||||
from .r2_uploader import upload_audio, upload_image, upload_video
|
||||
from .seedance_assets import (
|
||||
@@ -47,7 +49,7 @@ _MEDIA_RULES = {
|
||||
"last_frame": ({".png", ".jpg", ".jpeg", ".webp", ".bmp"}, SEEDANCE_REFERENCE_IMAGE_MAX_BYTES),
|
||||
"reference_images": ({".png", ".jpg", ".jpeg", ".webp", ".bmp"}, SEEDANCE_REFERENCE_IMAGE_MAX_BYTES),
|
||||
"reference_videos": ({".mp4", ".mov"}, SEEDANCE_REFERENCE_VIDEO_MAX_BYTES),
|
||||
"reference_audios": ({".wav", ".mp3", ".m4a", ".aac", ".flac", ".ogg"}, SEEDANCE_REFERENCE_AUDIO_MAX_BYTES),
|
||||
"reference_audios": (set(SEEDANCE_REFERENCE_AUDIO_EXTENSIONS), SEEDANCE_REFERENCE_AUDIO_MAX_BYTES),
|
||||
}
|
||||
_LIST_MEDIA_ROLES = {"reference_images", "reference_videos", "reference_audios"}
|
||||
_IMAGE_MEDIA_ROLES = {"first_frame", "last_frame", "reference_images"}
|
||||
@@ -195,6 +197,9 @@ def normalize_video_job_payload(payload: Any) -> dict[str, Any]:
|
||||
elif mode == "first_last_frame":
|
||||
if len(assets["images"]) != 2 or assets["videos"] or assets["audios"]:
|
||||
raise ValueError("首尾帧生视频的手动模式必须且只能填写两个图片素材 ID")
|
||||
elif mode in {"edit", "extend"}:
|
||||
if len(assets["videos"]) != 1:
|
||||
raise ValueError("视频编辑和视频延长必须且只能填写一个视频素材 ID")
|
||||
elif not asset_count:
|
||||
raise ValueError("多模态手动模式至少需要填写一个素材 ID")
|
||||
else:
|
||||
@@ -206,6 +211,11 @@ def normalize_video_job_payload(payload: Any) -> dict[str, Any]:
|
||||
elif mode == "first_last_frame":
|
||||
if not first_frame or not last_frame or reference_count or video_count or audio_count:
|
||||
raise ValueError("首尾帧生视频必须且只能提供首帧和尾帧图片")
|
||||
elif mode in {"edit", "extend"}:
|
||||
if video_count != 1 or first_frame or last_frame:
|
||||
raise ValueError("视频编辑和视频延长必须且只能提供一段参考视频")
|
||||
if not normalized["prompt"]:
|
||||
raise ValueError("视频编辑和视频延长必须填写提示词")
|
||||
elif not (
|
||||
normalized["prompt"]
|
||||
or reference_count
|
||||
@@ -236,6 +246,15 @@ def normalize_video_job_payload(payload: Any) -> dict[str, Any]:
|
||||
and not video_total
|
||||
):
|
||||
raise ValueError("Seedance 2.0 系列不可单独使用参考音频")
|
||||
if (
|
||||
mode == "multimodal"
|
||||
and normalized["model"] == "seedance-2.5"
|
||||
and audio_total
|
||||
and not image_total
|
||||
and not video_total
|
||||
and not normalized["prompt"]
|
||||
):
|
||||
raise ValueError("Seedance 2.5 仅有参考音频时必须填写提示词")
|
||||
|
||||
normalized.update({
|
||||
"batch_id": _canonical_batch_id(payload.get("batch_id")),
|
||||
@@ -322,22 +341,50 @@ def _probe_video_dimensions(path: str) -> tuple[int, int]:
|
||||
return width, height
|
||||
|
||||
|
||||
def _probe_media_seconds(path: str) -> float | None:
|
||||
"""Read the container duration used by the Seedance reference-time limits."""
|
||||
|
||||
try:
|
||||
import av
|
||||
except ImportError:
|
||||
raise ValueError("当前 ComfyUI 环境缺少 PyAV,无法校验参考素材时长") from None
|
||||
|
||||
try:
|
||||
with av.open(path) as container:
|
||||
if container.duration is None:
|
||||
return None
|
||||
return float(container.duration) / 1_000_000
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def snapshot_video_job_media(job: dict[str, Any], input_directory: str, temp_directory: str) -> None:
|
||||
batch_root = os.path.join(temp_directory, "o1key_video_jobs", job["batch_id"])
|
||||
input_root = os.path.join(batch_root, "inputs")
|
||||
os.makedirs(input_root, exist_ok=False)
|
||||
snapshots: dict[str, Any] = {}
|
||||
video_seconds: list[float] = []
|
||||
audio_seconds: list[float] = []
|
||||
for role, raw_value in job["media"].items():
|
||||
values = raw_value if isinstance(raw_value, list) else ([raw_value] if raw_value else [])
|
||||
copied = []
|
||||
for index, descriptor in enumerate(values, start=1):
|
||||
source = _resolve_input_path(input_directory, descriptor, role)
|
||||
_validate_media_file(source, role)
|
||||
if role == "reference_videos":
|
||||
seconds = _probe_media_seconds(source)
|
||||
if seconds is not None:
|
||||
video_seconds.append(seconds)
|
||||
elif role == "reference_audios":
|
||||
seconds = _probe_media_seconds(source)
|
||||
if seconds is not None:
|
||||
audio_seconds.append(seconds)
|
||||
extension = os.path.splitext(source)[1].lower()
|
||||
target = os.path.join(input_root, f"{role}_{index:02d}{extension}")
|
||||
shutil.copy2(source, target)
|
||||
copied.append(target)
|
||||
snapshots[role] = copied if role in _LIST_MEDIA_ROLES else (copied[0] if copied else None)
|
||||
validate_seedance_reference_durations(job["model"], video_seconds, audio_seconds)
|
||||
job["snapshot_root"] = batch_root
|
||||
job["snapshot_media"] = snapshots
|
||||
|
||||
@@ -375,7 +422,6 @@ async def _prepare_seedance_media(job: dict[str, Any], update) -> dict[str, Any]
|
||||
for kind in ("images", "videos", "audios")
|
||||
}
|
||||
return prepared
|
||||
|
||||
items = []
|
||||
if snapshots.get("first_frame"):
|
||||
items.append(("first_frame", "image", snapshots["first_frame"]))
|
||||
@@ -397,9 +443,10 @@ async def _prepare_seedance_media(job: dict[str, Any], update) -> dict[str, Any]
|
||||
job["resolved_assets"] = {"images": [], "videos": [], "audios": []}
|
||||
return prepared
|
||||
|
||||
request_type = seedance_asset_request_type(job["route"])
|
||||
direct_assets = job.get("asset_creation_mode") == "direct"
|
||||
request_type = "" if direct_assets else seedance_asset_request_type(job["route"])
|
||||
request_label = "HC" if request_type == "hc" else "Doubao"
|
||||
service = SeedanceAssetService(
|
||||
service = None if direct_assets else SeedanceAssetService(
|
||||
client=SeedanceElementClient(base_url=base_url),
|
||||
cache_path=job.get("asset_cache_path"),
|
||||
)
|
||||
@@ -409,9 +456,31 @@ async def _prepare_seedance_media(job: dict[str, Any], update) -> dict[str, Any]
|
||||
active_count = 0
|
||||
total = len(items)
|
||||
|
||||
async def upload_media(item_number: int, path: str, kind: str) -> str:
|
||||
nonlocal uploaded_count
|
||||
update(stage=f"上传素材 {item_number}/{total}")
|
||||
if kind == "image":
|
||||
with Image.open(path) as opened:
|
||||
opened.load()
|
||||
value = await upload_image(opened.convert("RGB"), base_url=base_url)
|
||||
elif kind == "video":
|
||||
value = await upload_video(path, base_url=base_url)
|
||||
else:
|
||||
value = await upload_audio(path, base_url=base_url)
|
||||
async with progress_lock:
|
||||
uploaded_count += 1
|
||||
update(
|
||||
stage=f"已上传素材 {uploaded_count}/{total}",
|
||||
progress=0.02 + (uploaded_count / total) * 0.08,
|
||||
)
|
||||
return value
|
||||
|
||||
async def prepare(item_number: int, path: str, kind: str) -> tuple[str, str]:
|
||||
nonlocal uploaded_count, active_count
|
||||
nonlocal active_count
|
||||
async with semaphore:
|
||||
if direct_assets:
|
||||
return await upload_media(item_number, path, kind), ""
|
||||
|
||||
fingerprint = await asyncio.to_thread(
|
||||
seedance_asset_fingerprint,
|
||||
path,
|
||||
@@ -420,22 +489,7 @@ async def _prepare_seedance_media(job: dict[str, Any], update) -> dict[str, Any]
|
||||
)
|
||||
|
||||
async def upload() -> str:
|
||||
nonlocal uploaded_count
|
||||
update(stage=f"上传素材 {item_number}/{total}")
|
||||
if kind == "image":
|
||||
with Image.open(path) as opened:
|
||||
opened.load()
|
||||
value = await upload_image(opened.convert("RGB"), base_url=base_url)
|
||||
elif kind == "video":
|
||||
value = await upload_video(path, base_url=base_url)
|
||||
else:
|
||||
value = await upload_audio(path, base_url=base_url)
|
||||
async with progress_lock:
|
||||
uploaded_count += 1
|
||||
update(
|
||||
stage=f"已上传素材 {uploaded_count}/{total}",
|
||||
progress=0.02 + (uploaded_count / total) * 0.06,
|
||||
)
|
||||
value = await upload_media(item_number, path, kind)
|
||||
update(stage=f"创建 {request_label} 素材 {item_number}/{total}")
|
||||
return value
|
||||
|
||||
@@ -464,20 +518,20 @@ async def _prepare_seedance_media(job: dict[str, Any], update) -> dict[str, Any]
|
||||
for item_number, (_role, kind, path) in enumerate(items, start=1)
|
||||
))
|
||||
resolved = {"images": [], "videos": [], "audios": []}
|
||||
for (role, kind, _path), (asset_url, asset_id) in zip(items, results):
|
||||
for (role, kind, _path), (url, asset_id) in zip(items, results):
|
||||
if role in {"first_frame", "last_frame"}:
|
||||
prepared[role] = asset_url
|
||||
prepared[role] = url
|
||||
else:
|
||||
prepared[role].append(asset_url)
|
||||
resolved[f"{kind}s"].append(asset_id)
|
||||
prepared[role].append(url)
|
||||
if asset_id:
|
||||
resolved[f"{kind}s"].append(asset_id)
|
||||
job["resolved_assets"] = resolved
|
||||
return prepared
|
||||
|
||||
|
||||
def build_seedance_video_body(job: dict[str, Any], prepared: dict[str, Any]) -> dict[str, Any]:
|
||||
content = []
|
||||
if job["prompt"]:
|
||||
content.append({"type": "text", "text": job["prompt"]})
|
||||
# content 必须包含至少一个非空文本项,纯参考素材请求也要带上提示词占位。
|
||||
content = [{"type": "text", "text": job["prompt"] or " "}]
|
||||
mode = job["generation_mode"]
|
||||
image_asset_ids = job["assets"].get("images", job["assets"].get("persons", []))
|
||||
manual_assets = job.get("asset_creation_mode") == "manual"
|
||||
@@ -486,6 +540,7 @@ def build_seedance_video_body(job: dict[str, Any], prepared: dict[str, Any]) ->
|
||||
content.append({
|
||||
"type": "image_url",
|
||||
"image_url": {"url": image_url},
|
||||
"role": "first_frame",
|
||||
})
|
||||
elif mode == "first_last_frame":
|
||||
image_urls = (
|
||||
@@ -506,11 +561,11 @@ def build_seedance_video_body(job: dict[str, Any], prepared: dict[str, Any]) ->
|
||||
},
|
||||
])
|
||||
elif mode == "multimodal":
|
||||
for index, asset_id in enumerate(image_asset_ids):
|
||||
for asset_id in image_asset_ids:
|
||||
content.append({
|
||||
"type": "image_url",
|
||||
"image_url": {"url": _asset_url(asset_id)},
|
||||
"role": "subject" if index == 0 else "reference_image",
|
||||
"role": "reference_image",
|
||||
})
|
||||
content.extend(
|
||||
{
|
||||
@@ -552,19 +607,64 @@ def build_seedance_video_body(job: dict[str, Any], prepared: dict[str, Any]) ->
|
||||
}
|
||||
for url in prepared["reference_audios"]
|
||||
)
|
||||
elif mode in {"edit", "extend"}:
|
||||
# 官方 2.5 的编辑/延长以参考视频为底片,同时允许附带参考图与参考音频。
|
||||
# 图片排在视频前面,保证提示词里 @image1 / @video1 的编号稳定。
|
||||
edit_image_urls = (
|
||||
[_asset_url(value) for value in job["assets"]["images"]]
|
||||
if manual_assets
|
||||
else prepared["reference_images"]
|
||||
)
|
||||
content.extend(
|
||||
{
|
||||
"type": "image_url",
|
||||
"image_url": {"url": url},
|
||||
"role": "reference_image",
|
||||
}
|
||||
for url in edit_image_urls
|
||||
)
|
||||
video_urls = (
|
||||
[_asset_url(value) for value in job["assets"]["videos"]]
|
||||
if manual_assets
|
||||
else prepared["reference_videos"]
|
||||
)
|
||||
content.extend(
|
||||
{
|
||||
"type": "video_url",
|
||||
"video_url": {"url": url},
|
||||
"role": "reference_video",
|
||||
}
|
||||
for url in video_urls
|
||||
)
|
||||
edit_audio_urls = (
|
||||
[_asset_url(value) for value in job["assets"]["audios"]]
|
||||
if manual_assets
|
||||
else prepared["reference_audios"]
|
||||
)
|
||||
content.extend(
|
||||
{
|
||||
"type": "audio_url",
|
||||
"audio_url": {"url": url},
|
||||
"role": "reference_audio",
|
||||
}
|
||||
for url in edit_audio_urls
|
||||
)
|
||||
|
||||
body = {
|
||||
"model": job["actual_model"],
|
||||
"content": content,
|
||||
"duration": job["duration"],
|
||||
"resolution": job["resolution"],
|
||||
"ratio": "16:9" if job["aspect_ratio"] == "auto" else job["aspect_ratio"],
|
||||
"ratio": "adaptive" if job["aspect_ratio"] == "auto" else job["aspect_ratio"],
|
||||
"generate_audio": job["generate_audio"],
|
||||
"watermark": False,
|
||||
"return_last_frame": job["return_last_frame"],
|
||||
}
|
||||
if job["seed"]:
|
||||
body["seed"] = job["seed"]
|
||||
if mode in {"edit", "extend"}:
|
||||
body["omni_reference_task_type"] = mode
|
||||
if job.get("output_format"):
|
||||
body["output_format"] = job["output_format"]
|
||||
# seed 只作为 ComfyUI 的缓存键,由上游自行生成,绝不随请求发送。
|
||||
return body
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user