Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6623ffa04c | ||
|
|
0ee8280ddb | ||
|
|
1fc8bdb8bb | ||
|
|
2c3c05277b | ||
|
|
2689f5354a | ||
|
|
7bd8c29faa | ||
|
|
4f3293fc02 | ||
|
|
4c87c6dea0 |
@@ -13,12 +13,14 @@ from calliope.comfyui.registry import (
|
||||
IMAGE_OUTPUT_CLASSES,
|
||||
IMAGE_URL_CLASSES,
|
||||
NUMBER_CLASSES,
|
||||
OPTIONAL_FRAME_INPUTS,
|
||||
TEXT_AREA_CLASSES,
|
||||
VIDEO_CLASSES,
|
||||
VIDEO_OUTPUT_CLASSES,
|
||||
ComfyOutputKind,
|
||||
class_to_input_kind,
|
||||
class_to_output_kind,
|
||||
optional_frame_sibling,
|
||||
)
|
||||
from calliope.comfyui.roles import (
|
||||
USAGE_VALUES,
|
||||
@@ -689,6 +691,8 @@ def detect_untagged_inputs(workflow: dict[str, Any]) -> list[dict[str, Any]]:
|
||||
)
|
||||
)
|
||||
|
||||
media = _with_optional_frames(workflow, media)
|
||||
|
||||
results: list[dict[str, Any]] = []
|
||||
positives = [t for t in texts if not t[3]]
|
||||
negatives = [t for t in texts if t[3]]
|
||||
@@ -732,6 +736,42 @@ def detect_untagged_inputs(workflow: dict[str, Any]) -> list[dict[str, Any]]:
|
||||
return results
|
||||
|
||||
|
||||
def _with_optional_frames(
|
||||
workflow: dict[str, Any], media: list[dict[str, Any]]
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Insert an optional slot after each frame slot whose node also accepts
|
||||
an unwired optional frame (H3 FL2VA: 首帧 → 尾帧)."""
|
||||
out = list(media)
|
||||
for nid, node in sorted(
|
||||
((str(k), v) for k, v in workflow.items() if isinstance(v, dict)),
|
||||
key=lambda kv: _node_sort_key(kv[0]),
|
||||
):
|
||||
for field in OPTIONAL_FRAME_INPUTS.get(str(node.get("class_type") or ""), {}):
|
||||
sibling = optional_frame_sibling(node, field)
|
||||
if sibling is None:
|
||||
continue
|
||||
loader_id = str(node["inputs"][sibling][0])
|
||||
loader = workflow.get(loader_id)
|
||||
if not isinstance(loader, dict) or loader.get("class_type") not in IMAGE_CLASSES:
|
||||
continue
|
||||
at = next(
|
||||
(
|
||||
i
|
||||
for i, e in enumerate(out)
|
||||
if e["nodeId"] == _key(loader_id, loader, "image")
|
||||
),
|
||||
None,
|
||||
)
|
||||
if at is None:
|
||||
continue
|
||||
role, label = _FRAME_SLOT_ROLES[field]
|
||||
out.insert(
|
||||
at + 1,
|
||||
_entry(f"{nid}{FIELD_KEY_SEP}{field}", label, role, "image", None, False),
|
||||
)
|
||||
return out
|
||||
|
||||
|
||||
def _is_negative(
|
||||
node_id: str, lowered_title: str, consumers: dict[str, list[tuple[str, str]]]
|
||||
) -> bool:
|
||||
|
||||
@@ -11,6 +11,7 @@ from calliope.comfyui.registry import (
|
||||
VIDEO_CLASSES,
|
||||
VIDEO_FILE_CLASSES,
|
||||
class_to_patch_field,
|
||||
optional_frame_sibling,
|
||||
)
|
||||
|
||||
# Input keys of the form "<nodeId>@<widget>" target one named widget on a
|
||||
@@ -142,6 +143,26 @@ def apply_media_group(
|
||||
apply_image_group = apply_media_group
|
||||
|
||||
|
||||
def apply_optional_frame(
|
||||
workflow: dict[str, Any], node_id: str, field: str, sibling: str, path: str
|
||||
) -> None:
|
||||
"""Wire ``path`` into an unwired optional frame input (H3 ``last_frame``)
|
||||
through a new LoadImage cloned from the ``sibling`` frame's loader."""
|
||||
node = workflow[node_id]
|
||||
inputs = dict(node.get("inputs") or {})
|
||||
src = workflow.get(str(inputs[sibling][0]))
|
||||
if isinstance(src, dict) and str(src.get("class_type") or "") in IMAGE_CLASSES:
|
||||
loader = copy.deepcopy(src)
|
||||
else:
|
||||
loader = {"class_type": "LoadImage", "inputs": {}}
|
||||
loader["inputs"] = {**(loader.get("inputs") or {}), "image": path}
|
||||
loader["_meta"] = {"title": "尾帧" if field == "last_frame" else field}
|
||||
nid = _next_node_id(workflow)
|
||||
workflow[nid] = loader
|
||||
inputs[field] = [nid, 0]
|
||||
node["inputs"] = inputs
|
||||
|
||||
|
||||
def patch_workflow(
|
||||
base: dict[str, Any],
|
||||
values_by_node_id: dict[str, Any],
|
||||
@@ -167,6 +188,10 @@ def patch_workflow(
|
||||
if clean:
|
||||
apply_media_group(patched, key, field, clean)
|
||||
continue
|
||||
if field is not None and (sibling := optional_frame_sibling(node, field)):
|
||||
if isinstance(value, str) and value.strip():
|
||||
apply_optional_frame(patched, key, field, sibling, value)
|
||||
continue
|
||||
if field is None:
|
||||
field = resolve_patch_field(node)
|
||||
elif isinstance(inputs.get(field), list):
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Unified class_type → kind + patch-field registry (MuseAgent port)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Literal
|
||||
from typing import Any, Literal
|
||||
|
||||
ComfyInputKind = Literal["text", "textarea", "number", "image", "image_url", "audio", "video"]
|
||||
ComfyOutputKind = Literal["image", "video", "other"]
|
||||
@@ -33,6 +33,24 @@ IMAGE_OUTPUT_CLASSES = frozenset(
|
||||
{"SaveImage", "PreviewImage", "SaveImageWebsocket", "ETN_SendImageWebSocket",
|
||||
"SaveImageAdvanced"}
|
||||
)
|
||||
# Frame-conditioned video nodes and the optional frame input an export may
|
||||
# leave unwired. MiniMax H3's FL2VA node takes `first_frame` plus an
|
||||
# optional `last_frame`; the studio offers the slot and the patcher adds
|
||||
# the LoadImage only when the user supplies that frame.
|
||||
OPTIONAL_FRAME_INPUTS: dict[str, dict[str, str]] = {
|
||||
"MiniMaxH3ImageToVideo": {"last_frame": "first_frame"},
|
||||
}
|
||||
|
||||
|
||||
def optional_frame_sibling(node: dict[str, Any], field: str) -> str | None:
|
||||
"""The wired frame input an unwired optional ``field`` mirrors
|
||||
(``last_frame`` → ``first_frame``); None when it does not apply."""
|
||||
inputs = node.get("inputs") or {}
|
||||
sibling = OPTIONAL_FRAME_INPUTS.get(str(node.get("class_type") or ""), {}).get(field)
|
||||
if sibling is None or field in inputs:
|
||||
return None
|
||||
link = inputs.get(sibling)
|
||||
return sibling if isinstance(link, list) and len(link) == 2 else None
|
||||
|
||||
|
||||
def class_to_input_kind(class_type: str) -> ComfyInputKind:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import sqlite3
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
@@ -410,6 +411,43 @@ def _backfill_workflow_output_map(conn: sqlite3.Connection) -> None:
|
||||
)
|
||||
|
||||
|
||||
# HEL-671: the user's H3 import went in under a first-frame-only name
|
||||
# (“H3图生视频·首帧…”) although its graph is the FL2VA node that also takes
|
||||
# a last frame. A row is renamed only when BOTH hold: its graph carries a
|
||||
# wired MiniMaxH3ImageToVideo node, and its name still reads like a
|
||||
# first-frame-only workflow — a row the user renamed, or any other graph,
|
||||
# is left alone. Idempotent: the new name no longer matches.
|
||||
_FIRST_FRAME_NAME_RE = re.compile(r"图生视频\s*[·\-—~]?\s*首帧")
|
||||
_FL2VA_DESCRIPTION = "首帧必填,尾帧可选:只传首帧为图生视频,同时传尾帧为首尾帧生视频"
|
||||
|
||||
|
||||
def _rename_workflows(conn: sqlite3.Connection) -> None:
|
||||
for wid, name, wf_json in conn.execute(
|
||||
"SELECT id, name, workflow_json FROM workflows"
|
||||
).fetchall():
|
||||
if not name or "尾帧" in name or not _FIRST_FRAME_NAME_RE.search(name):
|
||||
continue
|
||||
try:
|
||||
workflow = json.loads(wf_json) if wf_json else None
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
continue
|
||||
if not isinstance(workflow, dict):
|
||||
continue
|
||||
fl2va = any(
|
||||
isinstance(node, dict)
|
||||
and str(node.get("class_type") or "") == "MiniMaxH3ImageToVideo"
|
||||
and isinstance((node.get("inputs") or {}).get("first_frame"), list)
|
||||
for node in workflow.values()
|
||||
)
|
||||
if not fl2va:
|
||||
continue
|
||||
conn.execute(
|
||||
"UPDATE workflows SET name = ?,"
|
||||
" description = COALESCE(NULLIF(description, ''), ?) WHERE id = ?",
|
||||
(_FIRST_FRAME_NAME_RE.sub("首尾帧生视频", name), _FL2VA_DESCRIPTION, wid),
|
||||
)
|
||||
|
||||
|
||||
async def migrate_db(db_path: Path) -> None:
|
||||
db_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
conn = sqlite3.connect(db_path)
|
||||
@@ -472,6 +510,7 @@ async def migrate_db(db_path: Path) -> None:
|
||||
# upgrades can settle them); confirmed rows are never touched.
|
||||
_backfill_workflow_usage(conn)
|
||||
_backfill_workflow_output_map(conn)
|
||||
_rename_workflows(conn)
|
||||
scene_cols = {r[1] for r in conn.execute("PRAGMA table_info(scenes)").fetchall()}
|
||||
if "location_id" not in scene_cols:
|
||||
conn.execute("ALTER TABLE scenes ADD COLUMN location_id INTEGER")
|
||||
|
||||
@@ -36,6 +36,7 @@ QWEN_EDIT = "qwen21_edit_sage_API.json" # qwen-image-2.1-图片编辑-sage加
|
||||
EXAMPLES = Path(__file__).resolve().parents[2] / "example_ComfyUI_workflows"
|
||||
|
||||
REF_KEY = "131@ref_images"
|
||||
LAST_KEY = "131@last_frame"
|
||||
|
||||
|
||||
def _load(name: str) -> dict:
|
||||
@@ -61,7 +62,8 @@ def _ref_links(wf: dict, node_id: str = "131") -> list[tuple[str, str]]:
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_i2v_exposes_one_required_first_frame_and_no_last_frame():
|
||||
def test_i2v_exposes_required_first_frame_and_optional_last_frame():
|
||||
"""HEL-671: the 04 export is H3 FL2VA — `last_frame` is unwired but real."""
|
||||
inputs = parse_dynamic_inputs(_load(I2V))
|
||||
media = [i for i in inputs if i["kind"] in ("image", "image_list", "video", "audio")]
|
||||
assert media == [
|
||||
@@ -73,10 +75,36 @@ def test_i2v_exposes_one_required_first_frame_and_no_last_frame():
|
||||
"defaultValue": None,
|
||||
"required": True,
|
||||
"auto": True,
|
||||
}
|
||||
},
|
||||
{
|
||||
"nodeId": LAST_KEY,
|
||||
"label": "尾帧",
|
||||
"role": "last_frame",
|
||||
"kind": "image",
|
||||
"defaultValue": None,
|
||||
"required": False,
|
||||
"auto": True,
|
||||
},
|
||||
]
|
||||
# the title comment about FL2V is not a slot
|
||||
assert not any(i.get("role") == "last_frame" for i in inputs)
|
||||
|
||||
|
||||
def test_wired_last_frame_is_its_own_slot_not_a_second_virtual_one():
|
||||
wf = _load(I2V)
|
||||
wf["950"] = {"class_type": "LoadImage", "inputs": {"image": "last.png"}}
|
||||
wf["131"]["inputs"]["last_frame"] = ["950", 0]
|
||||
media = [i for i in parse_dynamic_inputs(wf) if i["kind"] == "image"]
|
||||
assert [(i["nodeId"], i["role"], i["required"]) for i in media] == [
|
||||
("901", "first_frame", True),
|
||||
("950", "last_frame", True),
|
||||
]
|
||||
|
||||
|
||||
def test_first_frame_through_a_custom_loader_gets_no_last_frame_slot():
|
||||
# Repo example: VHS_LoadImagePath → resize → first_frame; no slot pair to mirror.
|
||||
wf = json.loads(
|
||||
(EXAMPLES / "minimax_h3-Turbo_Image2Video_20260813_API.json").read_text(encoding="utf-8")
|
||||
)
|
||||
assert not any(i.get("role") == "last_frame" for i in parse_dynamic_inputs(wf))
|
||||
|
||||
|
||||
def test_ref2v_exposes_one_group_of_one_to_nine_reference_images():
|
||||
@@ -201,6 +229,29 @@ def test_single_slot_values_patch_first_frame_and_qwen_input():
|
||||
assert qwen["4"]["inputs"]["resolution"] == 1536
|
||||
|
||||
|
||||
def test_patch_last_frame_adds_its_own_load_image():
|
||||
base = _load(I2V)
|
||||
wf = patch_workflow(base, {"901": "/u/first.png", LAST_KEY: "/u/last.png"})
|
||||
node = wf["131"]["inputs"]
|
||||
assert node["first_frame"] == ["901", 0]
|
||||
last_id = node["last_frame"][0]
|
||||
assert last_id not in base and node["last_frame"] == [last_id, 0]
|
||||
assert wf[last_id]["class_type"] == "LoadImage"
|
||||
assert wf[last_id]["inputs"] == {"image": "/u/last.png"}
|
||||
assert wf["901"]["inputs"]["image"] == "/u/first.png"
|
||||
# base untouched; patching the result again rewires nothing
|
||||
assert "last_frame" not in base["131"]["inputs"]
|
||||
again = patch_workflow(wf, {LAST_KEY: "/u/other.png"})
|
||||
assert again["131"]["inputs"]["last_frame"] == [last_id, 0]
|
||||
|
||||
|
||||
def test_patch_without_last_frame_leaves_first_frame_only_graph():
|
||||
for values in ({"901": "/u/first.png"}, {"901": "/u/first.png", LAST_KEY: ""}):
|
||||
wf = patch_workflow(_load(I2V), values)
|
||||
assert "last_frame" not in wf["131"]["inputs"]
|
||||
assert sorted(wf) == sorted(_load(I2V))
|
||||
|
||||
|
||||
def test_legacy_job_values_keyed_by_load_image_still_patch():
|
||||
"""Jobs queued before HEL-633 carry the LoadImage id, not the group key."""
|
||||
wf = patch_workflow(_load(REF), {"901": "/assets/uploads/old.png"})
|
||||
@@ -265,6 +316,14 @@ def test_validate_rejects_bad_reference_files(uploads_dir):
|
||||
def test_validate_requires_first_frame_and_input_image():
|
||||
_, errs = validate_input_values(parse_dynamic_inputs(_load(I2V)), {"1": "p"})
|
||||
assert errs == ["请上传首帧"]
|
||||
_, errs = validate_input_values(
|
||||
parse_dynamic_inputs(_load(I2V)), {"1": "p", LAST_KEY: "/u/l.png"}
|
||||
)
|
||||
assert errs == ["请上传首帧"]
|
||||
clean, errs = validate_input_values(
|
||||
parse_dynamic_inputs(_load(I2V)), {"1": "p", "901": "/u/f.png"}
|
||||
)
|
||||
assert errs == [] and LAST_KEY not in clean
|
||||
_, errs = validate_input_values(parse_dynamic_inputs(_load(QWEN_EDIT)), {"4@prompt": "p"})
|
||||
assert errs == ["请上传输入图"]
|
||||
|
||||
@@ -403,9 +462,67 @@ def test_i2v_chain_uploads_first_frame(client, named_comfy):
|
||||
prompt = named_comfy.prompts[0]["prompt"]
|
||||
assert prompt["901"]["inputs"]["image"] == f"calliope/{Path(first).name}"
|
||||
assert prompt["131"]["inputs"]["first_frame"] == ["901", 0]
|
||||
assert "last_frame" not in prompt["131"]["inputs"]
|
||||
assert prompt["124"]["inputs"]["denoise"] == 0.8
|
||||
|
||||
|
||||
def test_fl2v_chain_uploads_first_and_last_frame_into_their_own_inputs(client, named_comfy):
|
||||
with _real_run(client, named_comfy):
|
||||
wf_id = _import_workflow(client, "H3 首尾帧生视频", "video", _load(I2V))
|
||||
listed = next(w for w in client.get("/api/workflows").json() if w["id"] == wf_id)
|
||||
assert listed["usage"] == "image2video"
|
||||
slots = {i["nodeId"]: i for i in listed["input_schema"] if i["kind"] == "image"}
|
||||
assert slots["901"]["role"] == "first_frame" and slots[LAST_KEY]["role"] == "last_frame"
|
||||
last = _upload(client, "尾帧.png")
|
||||
r = _generate(client, wf_id, {"1": "从白天过渡到夜晚", LAST_KEY: last})
|
||||
assert r.status_code == 400 and "请上传首帧" in r.json()["detail"]
|
||||
first = _upload(client, "首帧.png")
|
||||
r = _generate(client, wf_id, {"1": "从白天过渡到夜晚", "901": first, LAST_KEY: last})
|
||||
assert r.status_code == 200, r.text
|
||||
assert _wait_done(client, r.json()["job"]["id"])["status"] == "done"
|
||||
prompt = named_comfy.prompts[0]["prompt"]
|
||||
node = prompt["131"]["inputs"]
|
||||
assert prompt[node["first_frame"][0]]["inputs"]["image"] == f"calliope/{Path(first).name}"
|
||||
assert prompt[node["last_frame"][0]]["inputs"]["image"] == f"calliope/{Path(last).name}"
|
||||
assert node["first_frame"][0] != node["last_frame"][0]
|
||||
assert sorted(named_comfy.upload_names) == sorted([Path(first).name, Path(last).name])
|
||||
|
||||
|
||||
def test_migration_renames_the_imported_first_frame_workflow(tmp_path):
|
||||
import asyncio
|
||||
import sqlite3
|
||||
|
||||
from calliope.db import migrate_db
|
||||
|
||||
db = tmp_path / "c.db"
|
||||
asyncio.run(migrate_db(db))
|
||||
conn = sqlite3.connect(db)
|
||||
i2v, ref = json.dumps(_load(I2V)), json.dumps(_load(REF))
|
||||
conn.executemany(
|
||||
"INSERT INTO workflows (name, kind, workflow_json, description) VALUES (?, 'video', ?, ?)",
|
||||
[
|
||||
("H3 图生视频·首帧(04 用户提供)", i2v, None),
|
||||
("H3图生视频·首帧", i2v, "我自己写的说明"),
|
||||
("图生视频·首帧模板", ref, None), # not the FL2VA graph — left alone
|
||||
("我的视频工作流", i2v, None), # user already renamed — left alone
|
||||
],
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
asyncio.run(migrate_db(db))
|
||||
asyncio.run(migrate_db(db)) # idempotent
|
||||
conn = sqlite3.connect(db)
|
||||
rows = conn.execute("SELECT name, description FROM workflows ORDER BY id").fetchall()
|
||||
conn.close()
|
||||
assert rows[0] == (
|
||||
"H3 首尾帧生视频(04 用户提供)",
|
||||
"首帧必填,尾帧可选:只传首帧为图生视频,同时传尾帧为首尾帧生视频",
|
||||
)
|
||||
assert rows[1] == ("H3首尾帧生视频", "我自己写的说明") # suffix kept, description kept
|
||||
assert rows[2] == ("图生视频·首帧模板", None)
|
||||
assert rows[3] == ("我的视频工作流", None)
|
||||
|
||||
|
||||
def test_broken_qwen_import_warns_and_generation_is_refused(client, named_comfy):
|
||||
with _real_run(client, named_comfy):
|
||||
analyzed = client.post("/api/workflows/analyze", json={"workflow_json": _load(QWEN_EDIT)})
|
||||
|
||||
@@ -82,13 +82,16 @@ def test_a2_qwen_edit_variant_with_new_ids_titles_and_model_stays_image2image():
|
||||
assert len(mask) == 1 # mask never counts as an input image
|
||||
|
||||
|
||||
def test_a3_i2v_variant_renamed_still_image2video_first_frame_only():
|
||||
def test_a3_i2v_variant_renamed_still_image2video_with_optional_last_frame():
|
||||
wf = _rename_everything(_load(FIXTURES / "h3_i2v_04_API.json"))
|
||||
c = classify_usage(wf)
|
||||
assert c["usage"] == "image2video"
|
||||
media = _media(parse_dynamic_inputs(wf))
|
||||
assert [i.get("role") for i in media] == ["first_frame"]
|
||||
# A3: no first/last pair → the pair validation must not fire
|
||||
# HEL-671: the FL2VA node's unwired last_frame is offered, but optional
|
||||
assert [(i.get("role"), i["required"]) for i in media] == [
|
||||
("first_frame", True),
|
||||
("last_frame", False),
|
||||
]
|
||||
assert blocking_problem(wf) is None
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"test": "node scripts/check-storage-ssr.mjs && node scripts/check-random-uuid.mjs && node scripts/check-skill-frontmatter.mjs",
|
||||
"test": "node scripts/check-storage-ssr.mjs && node scripts/check-random-uuid.mjs && node scripts/check-skill-frontmatter.mjs && node scripts/check-export-frame.mjs",
|
||||
"lint": "prettier --check . && eslint .",
|
||||
"format": "prettier --write ."
|
||||
},
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Pure-logic checks for 导出尾帧 (lib/media/exportFrame.ts): which media
|
||||
* times get tried near the end, how the PNG is named, and when a sampled
|
||||
* frame counts as black / empty. The decode + download path itself runs in
|
||||
* a real browser (e2e/lastframe.mjs).
|
||||
*
|
||||
* Run with `npm test` (or `node scripts/check-export-frame.mjs`).
|
||||
*/
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath, pathToFileURL } from "node:url";
|
||||
|
||||
const HERE = dirname(fileURLToPath(import.meta.url));
|
||||
const MODULE = join(HERE, "..", "src", "lib", "media", "exportFrame.ts");
|
||||
|
||||
const {
|
||||
tailSeekTimes,
|
||||
videoBaseName,
|
||||
frameFileName,
|
||||
blankKind,
|
||||
statusErrorCode,
|
||||
TAIL_OFFSETS,
|
||||
} = await import(pathToFileURL(MODULE).href);
|
||||
|
||||
let failures = 0;
|
||||
function check(name, cond, extra = "") {
|
||||
if (cond) console.log(`ok ${name}`);
|
||||
else {
|
||||
failures += 1;
|
||||
console.error(`FAIL ${name}${extra ? ` — ${extra}` : ""}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- seek targets -------------------------------------------------------
|
||||
|
||||
const t6 = tailSeekTimes(6.04);
|
||||
check(
|
||||
"first try is ~1 frame before the end, never the end itself",
|
||||
t6[0] < 6.04 && 6.04 - t6[0] <= 0.05 + 1e-9,
|
||||
JSON.stringify(t6),
|
||||
);
|
||||
check(
|
||||
"later tries step strictly further back",
|
||||
t6.every((t, i) => i === 0 || t < t6[i - 1]),
|
||||
JSON.stringify(t6),
|
||||
);
|
||||
check(
|
||||
"tries stay within ~1s of the end",
|
||||
t6.length === TAIL_OFFSETS.length && 6.04 - t6[t6.length - 1] <= 1 + 1e-9,
|
||||
);
|
||||
check(
|
||||
"short clip clamps to 0 without duplicates",
|
||||
JSON.stringify(tailSeekTimes(0.1)) === "[0.05,0]",
|
||||
);
|
||||
check(
|
||||
"unknown / zero duration falls back to t=0",
|
||||
JSON.stringify(tailSeekTimes(NaN)) === "[0]" &&
|
||||
JSON.stringify(tailSeekTimes(0)) === "[0]",
|
||||
);
|
||||
|
||||
// ---- file names ---------------------------------------------------------
|
||||
|
||||
const api =
|
||||
"/api/file?path=" +
|
||||
encodeURIComponent(
|
||||
"/opt/aigc-home/data/assets/1/video/05_ref2va_4step_sla_00035_.mp4",
|
||||
);
|
||||
check(
|
||||
"base name from /api/file?path=…",
|
||||
videoBaseName(api) === "05_ref2va_4step_sla_00035_",
|
||||
);
|
||||
check(
|
||||
"base name from a Windows path",
|
||||
videoBaseName(
|
||||
"/api/file?path=" +
|
||||
encodeURIComponent("D:\\calliope\\assets\\镜头 01.webm"),
|
||||
) === "镜头 01",
|
||||
);
|
||||
check(
|
||||
"base name from a plain URL",
|
||||
videoBaseName("http://x.test/media/clip-9.mov?x=1") === "clip-9",
|
||||
);
|
||||
check(
|
||||
"unsafe characters are replaced",
|
||||
!/[:*?"<>|]/.test(
|
||||
videoBaseName("/api/file?path=" + encodeURIComponent('a:b*c?"d<e>f|g.mp4')),
|
||||
),
|
||||
);
|
||||
check(
|
||||
"blob URL without a name falls back to 'video'",
|
||||
videoBaseName("blob:http://x.test/") === "video",
|
||||
);
|
||||
const fname = frameFileName(api, 5.958, "尾帧");
|
||||
check(
|
||||
"PNG name names the video, the tag and the frame time",
|
||||
fname === "05_ref2va_4step_sla_00035__尾帧_5.958s.png",
|
||||
fname,
|
||||
);
|
||||
check(
|
||||
"spaces in the tag become dashes",
|
||||
frameFileName(api, 1, "last frame").includes("_last-frame_1.000s.png"),
|
||||
);
|
||||
|
||||
// ---- black / empty detection -------------------------------------------
|
||||
|
||||
function frame(n, rgba) {
|
||||
const out = new Uint8ClampedArray(n * 4);
|
||||
for (let i = 0; i < n; i++) out.set(rgba(i), i * 4);
|
||||
return out;
|
||||
}
|
||||
const N = 64 * 64;
|
||||
check(
|
||||
"fully transparent sample → empty",
|
||||
blankKind(frame(N, () => [0, 0, 0, 0])) === "empty",
|
||||
);
|
||||
check(
|
||||
"pure black → black",
|
||||
blankKind(frame(N, () => [0, 0, 0, 255])) === "black",
|
||||
);
|
||||
check(
|
||||
"near-black encoder noise (16..18) → black",
|
||||
blankKind(frame(N, (i) => [16 + (i % 3), 16, 16, 255])) === "black",
|
||||
);
|
||||
check(
|
||||
"mid-grey picture → not blank",
|
||||
blankKind(frame(N, () => [128, 128, 128, 255])) === null,
|
||||
);
|
||||
check(
|
||||
"dim but visible picture (≈50) → not blank",
|
||||
blankKind(frame(N, () => [50, 48, 52, 255])) === null,
|
||||
);
|
||||
check(
|
||||
"dark night scene with a bright highlight → not blank",
|
||||
blankKind(
|
||||
frame(N, (i) => (i === 100 ? [250, 240, 200, 255] : [4, 4, 6, 255])),
|
||||
) === null,
|
||||
);
|
||||
|
||||
// ---- HTTP status classification ----------------------------------------
|
||||
|
||||
check("404 → not-found", statusErrorCode(404) === "not-found");
|
||||
check(
|
||||
"403 → forbidden",
|
||||
statusErrorCode(403) === "forbidden" && statusErrorCode(401) === "forbidden",
|
||||
);
|
||||
check("500 → network", statusErrorCode(500) === "network");
|
||||
check(
|
||||
"206 / 200 are not errors",
|
||||
statusErrorCode(206) === null && statusErrorCode(200) === null,
|
||||
);
|
||||
|
||||
if (failures) {
|
||||
console.error(`\n${failures} export-frame check(s) failed.`);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log("export-frame checks passed.");
|
||||
@@ -1,7 +1,9 @@
|
||||
<script lang="ts">
|
||||
import SafeMedia from '$lib/components/SafeMedia.svelte';
|
||||
import Icon from '$lib/components/ui/Icon.svelte';
|
||||
import Spinner from '$lib/components/ui/Spinner.svelte';
|
||||
import { t } from '$lib/i18n.svelte';
|
||||
import { exportLastFrame } from '$lib/media/lastFrame';
|
||||
|
||||
interface Props {
|
||||
src: string | null;
|
||||
@@ -61,6 +63,17 @@
|
||||
}
|
||||
return alt ? `${alt.trim().replace(/\s+/g, '-').toLowerCase()}.png` : 'media';
|
||||
});
|
||||
|
||||
let frameBusy = $state(false);
|
||||
async function exportTail() {
|
||||
if (!src || frameBusy) return;
|
||||
frameBusy = true;
|
||||
try {
|
||||
await exportLastFrame(src);
|
||||
} finally {
|
||||
frameBusy = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:window onkeydown={src ? onKeydown : undefined} />
|
||||
@@ -90,6 +103,26 @@ aria-label={zoomed ? t('lightbox.fitToScreen') : t('lightbox.zoom100')}
|
||||
<Icon name="zoom-in" size={17} />
|
||||
</button>
|
||||
{/if}
|
||||
{#if isVideo}
|
||||
<button
|
||||
class="tool"
|
||||
type="button"
|
||||
aria-label={frameBusy ? t('lastFrame.exporting') : t('lastFrame.export')}
|
||||
title={frameBusy ? t('lastFrame.exporting') : `${t('lastFrame.export')} · ${t('lastFrame.hint')}`}
|
||||
disabled={frameBusy}
|
||||
aria-busy={frameBusy}
|
||||
onclick={(e) => {
|
||||
e.stopPropagation();
|
||||
exportTail();
|
||||
}}
|
||||
>
|
||||
{#if frameBusy}
|
||||
<Spinner size="sm" />
|
||||
{:else}
|
||||
<Icon name="image" size={17} />
|
||||
{/if}
|
||||
</button>
|
||||
{/if}
|
||||
<a
|
||||
class="tool"
|
||||
href={src}
|
||||
|
||||
@@ -62,7 +62,8 @@
|
||||
position: fixed;
|
||||
right: 24px;
|
||||
bottom: 24px;
|
||||
z-index: 1000;
|
||||
/* Above every overlay, incl. the 10000 lightbox, so feedback stays visible. */
|
||||
z-index: 10001;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
import { parseDbTs } from '$lib/dbtime';
|
||||
import { clearOutputMissing, markOutputMissing, missingOutputsOf } from '$lib/missingOutputs.svelte';
|
||||
import { t } from '$lib/i18n.svelte';
|
||||
import { exportLastFrame } from '$lib/media/lastFrame';
|
||||
import { usageLabel } from './schema';
|
||||
import { elapsedSec, fmtClock, fmtDur, inputsOf, isVideoOutput, promptOf, specOf } from './takes';
|
||||
|
||||
@@ -129,6 +130,18 @@
|
||||
}
|
||||
|
||||
const mediaKey = $derived(`${job?.id ?? 'none'}:${output ?? st?.tone ?? ''}`);
|
||||
|
||||
let frameBusy = $state(false);
|
||||
async function exportTail() {
|
||||
const src = assetUrl(output);
|
||||
if (!src || frameBusy) return;
|
||||
frameBusy = true;
|
||||
try {
|
||||
await exportLastFrame(src);
|
||||
} finally {
|
||||
frameBusy = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<aside class="inspector" class:open inert={inactive} aria-label={t('desk.inspector')}>
|
||||
@@ -154,28 +167,34 @@
|
||||
<div class="stage-media" in:xfade out:xfade>
|
||||
{#if output && video}
|
||||
<!-- svelte-ignore a11y_media_has_caption -->
|
||||
<video
|
||||
bind:this={videoEl}
|
||||
src={assetUrl(output)}
|
||||
controls
|
||||
playsinline
|
||||
preload="metadata"
|
||||
onloadedmetadata={(e) => {
|
||||
clearOutputMissing(output);
|
||||
noteVideo(e);
|
||||
}}
|
||||
onerror={() => output && markOutputMissing(output)}
|
||||
></video>
|
||||
<div class="print a-photo">
|
||||
{#if st.tone === 'ok' && !fileGone}<span class="a-fix">{t('jobst.done')}</span>{/if}
|
||||
<video
|
||||
bind:this={videoEl}
|
||||
src={assetUrl(output)}
|
||||
controls
|
||||
playsinline
|
||||
preload="metadata"
|
||||
onloadedmetadata={(e) => {
|
||||
clearOutputMissing(output);
|
||||
noteVideo(e);
|
||||
}}
|
||||
onerror={() => output && markOutputMissing(output)}
|
||||
></video>
|
||||
</div>
|
||||
{:else if output}
|
||||
<img
|
||||
src={assetUrl(output)}
|
||||
alt={prompt || t('desk.tabResult')}
|
||||
onload={(e) => {
|
||||
clearOutputMissing(output);
|
||||
noteImg(e);
|
||||
}}
|
||||
onerror={() => output && markOutputMissing(output)}
|
||||
/>
|
||||
<div class="print a-photo">
|
||||
{#if st.tone === 'ok' && !fileGone}<span class="a-fix">{t('jobst.done')}</span>{/if}
|
||||
<img
|
||||
src={assetUrl(output)}
|
||||
alt={prompt || t('desk.tabResult')}
|
||||
onload={(e) => {
|
||||
clearOutputMissing(output);
|
||||
noteImg(e);
|
||||
}}
|
||||
onerror={() => output && markOutputMissing(output)}
|
||||
/>
|
||||
</div>
|
||||
{:else if fileGone}
|
||||
<div class="stage-empty gone">
|
||||
<span>{t('desk.missingTitle')}</span>
|
||||
@@ -240,6 +259,18 @@
|
||||
{#if output}
|
||||
<a class="a-btn secondary sm" href={assetUrl(output)} download>{t('desk.download')}</a>
|
||||
{/if}
|
||||
{#if output && video}
|
||||
<button
|
||||
type="button"
|
||||
class="a-btn secondary sm"
|
||||
title={t('lastFrame.hint')}
|
||||
disabled={frameBusy}
|
||||
aria-busy={frameBusy}
|
||||
onclick={exportTail}
|
||||
>
|
||||
{frameBusy ? t('lastFrame.exporting') : t('lastFrame.export')}
|
||||
</button>
|
||||
{/if}
|
||||
{#if st.tone === 'fail'}
|
||||
<button type="button" class="a-btn secondary sm" onclick={() => onRetry(job)}>{t('common.retry')}</button>
|
||||
{/if}
|
||||
@@ -337,14 +368,24 @@
|
||||
inset: 0;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: var(--sp-5);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.stage-media > img,
|
||||
.stage-media > video {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: contain;
|
||||
/* 相纸白边 (HEL-680):检视舞台上的结果按相纸呈现,媒体自适应内含 */
|
||||
.print {
|
||||
position: relative;
|
||||
display: grid;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
--paper-w: 5px;
|
||||
}
|
||||
.print > img,
|
||||
.print > video {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
}
|
||||
.stage-empty {
|
||||
display: grid;
|
||||
|
||||
@@ -154,6 +154,7 @@
|
||||
{@const reject = rejects[s.inp.nodeId]?.[0]}
|
||||
<MediaSlot
|
||||
label={s.label}
|
||||
hint={s.lastFrame && !s.inp.required ? t('studio.slotOptional') : undefined}
|
||||
required={s.inp.required}
|
||||
value={String(values[s.inp.nodeId] ?? '')}
|
||||
kind={s.mediaKind}
|
||||
|
||||
@@ -183,7 +183,8 @@
|
||||
|
||||
<div class="out">
|
||||
{#if output}
|
||||
<div class="thumb" class:portrait>
|
||||
<div class="thumb a-photo" class:portrait>
|
||||
{#if st.tone === 'ok' && !fileGone}<span class="a-fix">{t('jobst.done')}</span>{/if}
|
||||
{#if isVideoOutput(job, output)}
|
||||
<video
|
||||
src={assetUrl(output)}
|
||||
@@ -238,15 +239,42 @@
|
||||
background-color var(--d-state) ease,
|
||||
box-shadow var(--d-state) ease;
|
||||
}
|
||||
/* 选中框:金色描边从上一条记录滑到新选中的记录(feed 驱动 WAAPI) */
|
||||
/* 选中框:取景框角线从上一条记录滑到新选中的记录(feed 驱动 WAAPI,
|
||||
HEL-680 四角短线取代整框描边) */
|
||||
.sel-mark {
|
||||
position: absolute;
|
||||
inset: -1px;
|
||||
z-index: 3;
|
||||
display: none;
|
||||
border: 1px solid var(--accent-line);
|
||||
border-radius: inherit;
|
||||
pointer-events: none;
|
||||
background-image:
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0);
|
||||
background-position:
|
||||
left top,
|
||||
left top,
|
||||
right top,
|
||||
right top,
|
||||
left bottom,
|
||||
left bottom,
|
||||
right bottom,
|
||||
right bottom;
|
||||
background-size:
|
||||
14px 2px,
|
||||
2px 14px,
|
||||
14px 2px,
|
||||
2px 14px,
|
||||
14px 2px,
|
||||
2px 14px,
|
||||
14px 2px,
|
||||
2px 14px;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.take.selected {
|
||||
border-color: transparent;
|
||||
@@ -458,6 +486,12 @@
|
||||
background: var(--bg-4);
|
||||
box-shadow: inset 0 0 0 1px var(--on-media-line);
|
||||
}
|
||||
/* 相纸白边 (HEL-680):有产出的记录缩略图按相纸呈现,压过占位态样式 */
|
||||
.thumb.a-photo {
|
||||
border-radius: 2px;
|
||||
background: var(--accent);
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
|
||||
}
|
||||
.thumb.portrait {
|
||||
width: 96px;
|
||||
aspect-ratio: 3 / 4;
|
||||
|
||||
@@ -282,7 +282,9 @@ export function validateForm(
|
||||
if (first && last) {
|
||||
const a = String(values[first.inp.nodeId] ?? '');
|
||||
const b = String(values[last.inp.nodeId] ?? '');
|
||||
if ((!a || !b) && (a || b)) {
|
||||
// An optional last frame (H3 FL2VA) may stay empty; it never goes without a first frame.
|
||||
const unpaired = last.inp.required ? (!a || !b) && (a || b) : !a && !!b;
|
||||
if (unpaired) {
|
||||
errs.firstLast = t('studio.errFirstLast');
|
||||
if (!a) errs[first.inp.nodeId] = ' ';
|
||||
if (!b) errs[last.inp.nodeId] = ' ';
|
||||
|
||||
@@ -52,7 +52,12 @@
|
||||
'var(--avatar-4)',
|
||||
'var(--avatar-5)',
|
||||
];
|
||||
const placeholder = $derived(PLACEHOLDER_GRADIENTS[project.id % PLACEHOLDER_GRADIENTS.length]);
|
||||
const placeholderIdx = $derived(project.id % PLACEHOLDER_GRADIENTS.length);
|
||||
const placeholder = $derived(PLACEHOLDER_GRADIENTS[placeholderIdx]);
|
||||
// HEL-680 灰阶封面占位:1–2 亮阶配深图标,3–5 暗阶配浅图标
|
||||
const placeholderIconColor = $derived(
|
||||
placeholderIdx <= 1 ? 'var(--accent-ink)' : 'var(--text)',
|
||||
);
|
||||
|
||||
const coverUrl = $derived(assetUrl(project.cover_path));
|
||||
|
||||
@@ -174,7 +179,12 @@
|
||||
onerror={() => (coverFailed = true)}
|
||||
/>
|
||||
{:else}
|
||||
<span class="cover-ph" style:background={placeholder} aria-hidden="true">
|
||||
<span
|
||||
class="cover-ph"
|
||||
style:background={placeholder}
|
||||
style:color={placeholderIconColor}
|
||||
aria-hidden="true"
|
||||
>
|
||||
<Icon name="film" size={22} />
|
||||
</span>
|
||||
{/if}
|
||||
|
||||
@@ -402,6 +402,7 @@
|
||||
flex-shrink: 0;
|
||||
margin-bottom: var(--sp-5);
|
||||
border-radius: var(--r-md);
|
||||
border-bottom: 2px solid var(--accent-lo);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: var(--accent-grad);
|
||||
|
||||
@@ -132,9 +132,7 @@ let {
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background:
|
||||
radial-gradient(ellipse at center, rgba(139, 92, 246, 0.08), transparent 55%),
|
||||
#050508;
|
||||
background: var(--stage-bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
overflow: hidden;
|
||||
|
||||
@@ -79,14 +79,14 @@
|
||||
let criticNotes = $state<string[]>([]);
|
||||
|
||||
const preview = createMutation({
|
||||
mutationFn: async (vars?: { force?: boolean }) => {
|
||||
mutationFn: async (vars: { force?: boolean } | void) => {
|
||||
if (!clip && !scene) throw new Error(t('promptPreview.noClipSelected'));
|
||||
return jobsApi.previewPrompt(projectId, {
|
||||
clip_id: clip?.id,
|
||||
scene_id: clip ? undefined : scene?.id,
|
||||
workflow_id: workflow?.id,
|
||||
input_values: compactInputValues(inputValues),
|
||||
force: Boolean(vars?.force),
|
||||
force: Boolean((vars as { force?: boolean } | undefined)?.force),
|
||||
});
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
|
||||
@@ -203,7 +203,7 @@ title={t('filmstrip.clipTitle', {
|
||||
inset: 0 0 auto 0;
|
||||
height: 3px;
|
||||
z-index: 1;
|
||||
background: #3f3f46;
|
||||
background: var(--bg-4);
|
||||
}
|
||||
|
||||
.clip.status-done .bar {
|
||||
|
||||
@@ -221,6 +221,25 @@ export const de: Dict = {
|
||||
'lightbox.videoPreview': 'Videovorschau',
|
||||
'lightbox.videoUnavailable': 'Video nicht verfügbar',
|
||||
'lightbox.zoom100': '100%',
|
||||
'lastFrame.export': 'Letztes Bild exportieren',
|
||||
'lastFrame.exporting': 'Letztes Bild wird exportiert…',
|
||||
'lastFrame.hint': 'Speichert das letzte Bild in Originalgröße als PNG, z. B. als Startbild-Referenz',
|
||||
'lastFrame.fileTag': 'letztes-bild',
|
||||
'lastFrame.done': 'Letztes Bild exportiert {name} ({size})',
|
||||
'lastFrame.errTimeout': 'Das Video lädt zu lange. Bitte später erneut versuchen.',
|
||||
'lastFrame.errNotFound': 'Die Videodatei fehlt oder wurde entfernt.',
|
||||
'lastFrame.errForbidden': 'Keine Berechtigung, dieses Video zu lesen.',
|
||||
'lastFrame.errNetwork': 'Das Video konnte nicht gelesen werden (Netzwerkfehler).',
|
||||
'lastFrame.errDecode': 'Das Video ist beschädigt; das Ende lässt sich nicht dekodieren.',
|
||||
'lastFrame.errUnsupported': 'Dieser Browser unterstützt das Videoformat nicht, oder die Datei ist beschädigt.',
|
||||
'lastFrame.errCrossOrigin':
|
||||
'Das Video stammt von einer anderen Website, die das Auslesen von Bildern sperrt (Cross-Origin). Video zuerst herunterladen.',
|
||||
'lastFrame.errNoPicture': 'Diese Datei enthält kein Videobild.',
|
||||
'lastFrame.errUnseekable':
|
||||
'Das Videoende ist nicht erreichbar (Länge unbekannt oder Quelle erlaubt kein Springen); kein Bild exportiert.',
|
||||
'lastFrame.errBlack': 'Die letzte Sekunde des Videos ist schwarz; kein Bild exportiert.',
|
||||
'lastFrame.errEmpty': 'Der Browser konnte das Ende nicht dekodieren. Erneut versuchen oder Desktop-Chrome / Edge nutzen.',
|
||||
'lastFrame.errUnknown': 'Export des letzten Bildes fehlgeschlagen: {msg}',
|
||||
|
||||
// --- Artifact / canvas nodes ---
|
||||
'artifact.artifactLabel': 'Artefakt',
|
||||
@@ -1539,6 +1558,7 @@ export const de: Dict = {
|
||||
'studio.slotMask': 'Maske',
|
||||
'studio.slotFirst': 'Erster Frame',
|
||||
'studio.slotLast': 'Letzter Frame',
|
||||
'studio.slotOptional': 'Optional',
|
||||
'studio.slotRefVideo': 'Referenzvideo',
|
||||
'studio.slotAudio': 'Referenzaudio',
|
||||
'studio.slotPick': 'Klicken oder Datei ziehen',
|
||||
@@ -1882,7 +1902,7 @@ export const de: Dict = {
|
||||
'home.stageProgress': 'Fünf-Phasen-Fortschritt',
|
||||
'tasks.sourceWorkbench': 'Kreativ-Fluss',
|
||||
'jobst.idSuffix': ' · ComfyUI-Prompt-ID {id}',
|
||||
'jobst.done': 'Fertig',
|
||||
'jobst.done': 'Fixiert',
|
||||
'jobst.doneDetail': 'ComfyUI ist fertig, Ergebnisse gespeichert',
|
||||
'jobst.dryRun': 'Platzhalter',
|
||||
'jobst.dryRunDetail': 'Nur Platzhalter: Dry-run ist aktiv, ComfyUI wurde nicht aufgerufen',
|
||||
|
||||
@@ -221,6 +221,25 @@ export const en = {
|
||||
'lightbox.videoPreview': 'Video preview',
|
||||
'lightbox.videoUnavailable': 'Video unavailable',
|
||||
'lightbox.zoom100': '100%',
|
||||
'lastFrame.export': 'Export last frame',
|
||||
'lastFrame.exporting': 'Exporting last frame…',
|
||||
'lastFrame.hint': 'Save the final frame as a full-size PNG, e.g. as a first-frame reference',
|
||||
'lastFrame.fileTag': 'last-frame',
|
||||
'lastFrame.done': 'Exported last frame {name} ({size})',
|
||||
'lastFrame.errTimeout': 'The video took too long to load. Try again later.',
|
||||
'lastFrame.errNotFound': 'The video file is missing or was removed.',
|
||||
'lastFrame.errForbidden': 'You do not have permission to read this video.',
|
||||
'lastFrame.errNetwork': 'Reading the video failed (network error). Check the connection and retry.',
|
||||
'lastFrame.errDecode': 'The video is damaged; its ending cannot be decoded.',
|
||||
'lastFrame.errUnsupported': 'This browser cannot play the video format, or the file is damaged.',
|
||||
'lastFrame.errCrossOrigin':
|
||||
'The video comes from another site that blocks reading its frames (cross-origin). Download the video first.',
|
||||
'lastFrame.errNoPicture': 'This file has no video picture.',
|
||||
'lastFrame.errUnseekable':
|
||||
'Cannot reach the end of the video (unknown length, or the source does not allow seeking); no frame exported.',
|
||||
'lastFrame.errBlack': 'The last second of the video is black; no frame exported.',
|
||||
'lastFrame.errEmpty': 'The browser could not decode the ending. Retry, or use desktop Chrome / Edge.',
|
||||
'lastFrame.errUnknown': 'Exporting the last frame failed: {msg}',
|
||||
|
||||
// --- Artifact / canvas nodes ---
|
||||
'artifact.artifactLabel': 'Artifact',
|
||||
@@ -1538,6 +1557,7 @@ export const en = {
|
||||
'studio.slotMask': 'Mask',
|
||||
'studio.slotFirst': 'First frame',
|
||||
'studio.slotLast': 'Last frame',
|
||||
'studio.slotOptional': 'Optional',
|
||||
'studio.slotRefVideo': 'Reference video',
|
||||
'studio.slotAudio': 'Reference audio',
|
||||
'studio.slotPick': 'Click or drop a file',
|
||||
@@ -1881,7 +1901,7 @@ export const en = {
|
||||
'home.stageProgress': 'Five-stage progress',
|
||||
'tasks.sourceWorkbench': 'Creation flow',
|
||||
'jobst.idSuffix': ' · ComfyUI prompt ID {id}',
|
||||
'jobst.done': 'Done',
|
||||
'jobst.done': 'Fixed',
|
||||
'jobst.doneDetail': 'ComfyUI finished and the results are saved',
|
||||
'jobst.dryRun': 'Placeholder',
|
||||
'jobst.dryRunDetail': 'Placeholder only: Dry-run is on, ComfyUI was not called',
|
||||
|
||||
@@ -221,6 +221,25 @@ export const es: Dict = {
|
||||
'lightbox.videoPreview': 'Vista previa de vídeo',
|
||||
'lightbox.videoUnavailable': 'Vídeo no disponible',
|
||||
'lightbox.zoom100': '100%',
|
||||
'lastFrame.export': 'Exportar último fotograma',
|
||||
'lastFrame.exporting': 'Exportando último fotograma…',
|
||||
'lastFrame.hint': 'Guarda el último fotograma como PNG a tamaño completo, p. ej. como referencia de primer fotograma',
|
||||
'lastFrame.fileTag': 'ultimo-fotograma',
|
||||
'lastFrame.done': 'Último fotograma exportado {name} ({size})',
|
||||
'lastFrame.errTimeout': 'El vídeo tardó demasiado en cargar. Inténtalo más tarde.',
|
||||
'lastFrame.errNotFound': 'El archivo de vídeo no existe o fue eliminado.',
|
||||
'lastFrame.errForbidden': 'No tienes permiso para leer este vídeo.',
|
||||
'lastFrame.errNetwork': 'No se pudo leer el vídeo (error de red).',
|
||||
'lastFrame.errDecode': 'El vídeo está dañado; su final no se puede decodificar.',
|
||||
'lastFrame.errUnsupported': 'Este navegador no admite el formato del vídeo o el archivo está dañado.',
|
||||
'lastFrame.errCrossOrigin':
|
||||
'El vídeo procede de otro sitio que no permite leer sus fotogramas (origen cruzado). Descarga primero el vídeo.',
|
||||
'lastFrame.errNoPicture': 'Este archivo no tiene imagen de vídeo.',
|
||||
'lastFrame.errUnseekable':
|
||||
'No se puede llegar al final del vídeo (duración desconocida o el origen no permite buscar); no se exportó nada.',
|
||||
'lastFrame.errBlack': 'El último segundo del vídeo es negro; no se exportó ningún fotograma.',
|
||||
'lastFrame.errEmpty': 'El navegador no pudo decodificar el final. Reintenta o usa Chrome / Edge de escritorio.',
|
||||
'lastFrame.errUnknown': 'Error al exportar el último fotograma: {msg}',
|
||||
|
||||
// --- Artifact / canvas nodes ---
|
||||
'artifact.artifactLabel': 'Artefacto',
|
||||
@@ -1539,6 +1558,7 @@ export const es: Dict = {
|
||||
'studio.slotMask': 'Máscara',
|
||||
'studio.slotFirst': 'Primer fotograma',
|
||||
'studio.slotLast': 'Último fotograma',
|
||||
'studio.slotOptional': 'Opcional',
|
||||
'studio.slotRefVideo': 'Vídeo de referencia',
|
||||
'studio.slotAudio': 'Audio de referencia',
|
||||
'studio.slotPick': 'Haz clic o arrastra',
|
||||
@@ -1882,7 +1902,7 @@ export const es: Dict = {
|
||||
'home.stageProgress': 'Progreso de cinco etapas',
|
||||
'tasks.sourceWorkbench': 'Flujo de creación',
|
||||
'jobst.idSuffix': ' · ID de prompt de ComfyUI {id}',
|
||||
'jobst.done': 'Listo',
|
||||
'jobst.done': 'Fijado',
|
||||
'jobst.doneDetail': 'ComfyUI terminó y los resultados se guardaron',
|
||||
'jobst.dryRun': 'Marcador',
|
||||
'jobst.dryRunDetail': 'Solo marcador: Dry-run activo, no se llamó a ComfyUI',
|
||||
|
||||
@@ -221,6 +221,25 @@ export const fr: Dict = {
|
||||
'lightbox.videoPreview': 'Aperçu de la vidéo',
|
||||
'lightbox.videoUnavailable': 'Vidéo indisponible',
|
||||
'lightbox.zoom100': '100 %',
|
||||
'lastFrame.export': 'Exporter la dernière image',
|
||||
'lastFrame.exporting': 'Export de la dernière image…',
|
||||
'lastFrame.hint': 'Enregistre la dernière image en PNG pleine taille, p. ex. comme référence de première image',
|
||||
'lastFrame.fileTag': 'derniere-image',
|
||||
'lastFrame.done': 'Dernière image exportée {name} ({size})',
|
||||
'lastFrame.errTimeout': 'Le chargement de la vidéo a expiré. Réessayez plus tard.',
|
||||
'lastFrame.errNotFound': 'Le fichier vidéo est introuvable ou a été supprimé.',
|
||||
'lastFrame.errForbidden': "Vous n'avez pas l'autorisation de lire cette vidéo.",
|
||||
'lastFrame.errNetwork': 'Lecture de la vidéo impossible (erreur réseau).',
|
||||
'lastFrame.errDecode': 'La vidéo est endommagée ; sa fin ne peut pas être décodée.',
|
||||
'lastFrame.errUnsupported': 'Ce navigateur ne prend pas en charge ce format vidéo, ou le fichier est endommagé.',
|
||||
'lastFrame.errCrossOrigin':
|
||||
"La vidéo provient d'un autre site qui bloque la lecture des images (cross-origin). Téléchargez d'abord la vidéo.",
|
||||
'lastFrame.errNoPicture': "Ce fichier ne contient pas d'image vidéo.",
|
||||
'lastFrame.errUnseekable':
|
||||
"Impossible d'atteindre la fin de la vidéo (durée inconnue ou source sans recherche) ; aucune image exportée.",
|
||||
'lastFrame.errBlack': 'La dernière seconde de la vidéo est noire ; aucune image exportée.',
|
||||
'lastFrame.errEmpty': "Le navigateur n'a pas pu décoder la fin. Réessayez ou utilisez Chrome / Edge sur ordinateur.",
|
||||
'lastFrame.errUnknown': "Échec de l'export de la dernière image : {msg}",
|
||||
|
||||
// --- Artifact / canvas nodes ---
|
||||
'artifact.artifactLabel': 'Artefact',
|
||||
@@ -1539,6 +1558,7 @@ export const fr: Dict = {
|
||||
'studio.slotMask': 'Masque',
|
||||
'studio.slotFirst': 'Premier cadre',
|
||||
'studio.slotLast': 'Dernier cadre',
|
||||
'studio.slotOptional': 'Facultatif',
|
||||
'studio.slotRefVideo': 'Vidéo de référence',
|
||||
'studio.slotAudio': 'Audio de référence',
|
||||
'studio.slotPick': 'Cliquez ou déposez',
|
||||
@@ -1882,7 +1902,7 @@ export const fr: Dict = {
|
||||
'home.stageProgress': 'Progression en cinq étapes',
|
||||
'tasks.sourceWorkbench': 'Flux de création',
|
||||
'jobst.idSuffix': ' · ID de prompt ComfyUI {id}',
|
||||
'jobst.done': 'Terminé',
|
||||
'jobst.done': 'Fixé',
|
||||
'jobst.doneDetail': 'ComfyUI a terminé, résultats enregistrés',
|
||||
'jobst.dryRun': 'Substitut',
|
||||
'jobst.dryRunDetail': 'Substitut uniquement : Dry-run actif, ComfyUI n\'a pas été appelé',
|
||||
|
||||
@@ -221,6 +221,23 @@ export const ja: Dict = {
|
||||
'lightbox.videoPreview': 'ビデオプレビュー',
|
||||
'lightbox.videoUnavailable': 'ビデオを再生できません',
|
||||
'lightbox.zoom100': '100%',
|
||||
'lastFrame.export': '最終フレームを書き出す',
|
||||
'lastFrame.exporting': '最終フレームを書き出し中…',
|
||||
'lastFrame.hint': '動画の最後のフレームを元のサイズの PNG で保存します(先頭フレーム参照用)',
|
||||
'lastFrame.fileTag': '最終フレーム',
|
||||
'lastFrame.done': '最終フレームを書き出しました {name}({size})',
|
||||
'lastFrame.errTimeout': '動画の読み込みがタイムアウトしました。後でもう一度お試しください。',
|
||||
'lastFrame.errNotFound': '動画ファイルが存在しないか削除されています。',
|
||||
'lastFrame.errForbidden': 'この動画へのアクセス権限がありません。',
|
||||
'lastFrame.errNetwork': '動画の読み込みに失敗しました(ネットワークエラー)。',
|
||||
'lastFrame.errDecode': '動画が破損しており、末尾をデコードできません。',
|
||||
'lastFrame.errUnsupported': 'このブラウザーは動画形式に対応していないか、ファイルが破損しています。',
|
||||
'lastFrame.errCrossOrigin': '他サイトの動画のためフレームを読み取れません(クロスオリジン制限)。先に動画をダウンロードしてください。',
|
||||
'lastFrame.errNoPicture': 'このファイルには映像がありません。',
|
||||
'lastFrame.errUnseekable': '動画の末尾に移動できません(長さ不明、またはシーク非対応)。書き出しませんでした。',
|
||||
'lastFrame.errBlack': '動画の最後の 1 秒が黒画面のため、書き出しませんでした。',
|
||||
'lastFrame.errEmpty': '末尾をデコードできませんでした。再試行するか、PC の Chrome / Edge をお使いください。',
|
||||
'lastFrame.errUnknown': '最終フレームの書き出しに失敗しました:{msg}',
|
||||
|
||||
// --- Artifact / canvas nodes ---
|
||||
'artifact.artifactLabel': '成果物',
|
||||
@@ -1539,6 +1556,7 @@ export const ja: Dict = {
|
||||
'studio.slotMask': 'マスク',
|
||||
'studio.slotFirst': '始端フレーム',
|
||||
'studio.slotLast': '終端フレーム',
|
||||
'studio.slotOptional': '任意',
|
||||
'studio.slotRefVideo': '参照動画',
|
||||
'studio.slotAudio': '参照音声',
|
||||
'studio.slotPick': 'クリックまたはドロップ',
|
||||
@@ -1882,7 +1900,7 @@ export const ja: Dict = {
|
||||
'home.stageProgress': '五段階の進捗',
|
||||
'tasks.sourceWorkbench': '制作フロー',
|
||||
'jobst.idSuffix': ' · ComfyUI プロンプト ID {id}',
|
||||
'jobst.done': '完了',
|
||||
'jobst.done': '定着',
|
||||
'jobst.doneDetail': 'ComfyUI の実行が完了し、結果を保存しました',
|
||||
'jobst.dryRun': 'プレースホルダー',
|
||||
'jobst.dryRunDetail': 'プレースホルダーのみ:Dry-run が有効で ComfyUI は呼び出されていません',
|
||||
|
||||
@@ -221,6 +221,23 @@ export const ko: Dict = {
|
||||
'lightbox.videoPreview': '영상 미리보기',
|
||||
'lightbox.videoUnavailable': '영상을 표시할 수 없습니다',
|
||||
'lightbox.zoom100': '100%',
|
||||
'lastFrame.export': '마지막 프레임 내보내기',
|
||||
'lastFrame.exporting': '마지막 프레임 내보내는 중…',
|
||||
'lastFrame.hint': '영상의 마지막 프레임을 원본 크기 PNG로 저장합니다(첫 프레임 참조용)',
|
||||
'lastFrame.fileTag': '마지막프레임',
|
||||
'lastFrame.done': '마지막 프레임을 내보냈습니다 {name} ({size})',
|
||||
'lastFrame.errTimeout': '영상 로딩 시간이 초과되었습니다. 잠시 후 다시 시도하세요.',
|
||||
'lastFrame.errNotFound': '영상 파일이 없거나 삭제되었습니다.',
|
||||
'lastFrame.errForbidden': '이 영상에 접근할 권한이 없습니다.',
|
||||
'lastFrame.errNetwork': '영상을 읽지 못했습니다(네트워크 오류).',
|
||||
'lastFrame.errDecode': '영상이 손상되어 끝부분을 디코딩할 수 없습니다.',
|
||||
'lastFrame.errUnsupported': '이 브라우저가 영상 형식을 지원하지 않거나 파일이 손상되었습니다.',
|
||||
'lastFrame.errCrossOrigin': '다른 사이트의 영상이라 프레임을 읽을 수 없습니다(교차 출처 제한). 먼저 영상을 다운로드하세요.',
|
||||
'lastFrame.errNoPicture': '이 파일에는 영상 화면이 없습니다.',
|
||||
'lastFrame.errUnseekable': '영상 끝으로 이동할 수 없습니다(길이 불명 또는 탐색 미지원). 내보내지 않았습니다.',
|
||||
'lastFrame.errBlack': '영상의 마지막 1초가 검은 화면이라 내보내지 않았습니다.',
|
||||
'lastFrame.errEmpty': '끝부분을 디코딩하지 못했습니다. 다시 시도하거나 PC Chrome / Edge를 사용하세요.',
|
||||
'lastFrame.errUnknown': '마지막 프레임 내보내기 실패: {msg}',
|
||||
|
||||
// --- Artifact / canvas nodes ---
|
||||
'artifact.artifactLabel': '아티팩트',
|
||||
@@ -1539,6 +1556,7 @@ export const ko: Dict = {
|
||||
'studio.slotMask': '마스크',
|
||||
'studio.slotFirst': '첫 프레임',
|
||||
'studio.slotLast': '마지막 프레임',
|
||||
'studio.slotOptional': '선택',
|
||||
'studio.slotRefVideo': '참조 비디오',
|
||||
'studio.slotAudio': '참조 오디오',
|
||||
'studio.slotPick': '클릭하거나 끌어다 놓기',
|
||||
@@ -1882,7 +1900,7 @@ export const ko: Dict = {
|
||||
'home.stageProgress': '5단계 진행',
|
||||
'tasks.sourceWorkbench': '제작 흐름',
|
||||
'jobst.idSuffix': ' · ComfyUI 프롬프트 ID {id}',
|
||||
'jobst.done': '완료',
|
||||
'jobst.done': '정착',
|
||||
'jobst.doneDetail': 'ComfyUI 실행이 끝나 결과를 저장했습니다',
|
||||
'jobst.dryRun': '자리표시자',
|
||||
'jobst.dryRunDetail': '자리표시자만: Dry-run이 켜져 있어 ComfyUI를 호출하지 않았습니다',
|
||||
|
||||
@@ -221,6 +221,23 @@ export const zh: Dict = {
|
||||
'lightbox.videoPreview': '视频预览',
|
||||
'lightbox.videoUnavailable': '视频不可用',
|
||||
'lightbox.zoom100': '100%',
|
||||
'lastFrame.export': '导出尾帧',
|
||||
'lastFrame.exporting': '正在导出尾帧…',
|
||||
'lastFrame.hint': '把视频最后一帧按原尺寸保存为 PNG,可作首帧参考',
|
||||
'lastFrame.fileTag': '尾帧',
|
||||
'lastFrame.done': '已导出尾帧 {name}({size})',
|
||||
'lastFrame.errTimeout': '视频加载超时,未能导出尾帧,请稍后重试',
|
||||
'lastFrame.errNotFound': '视频文件不存在或已被移除,无法导出尾帧',
|
||||
'lastFrame.errForbidden': '没有访问该视频的权限,无法导出尾帧',
|
||||
'lastFrame.errNetwork': '视频读取失败(网络中断),请检查连接后重试',
|
||||
'lastFrame.errDecode': '视频文件已损坏,片尾画面无法解码',
|
||||
'lastFrame.errUnsupported': '当前浏览器不支持该视频格式,或文件已损坏,无法导出尾帧',
|
||||
'lastFrame.errCrossOrigin': '该视频来自其他站点,浏览器禁止读取画面(跨域限制),请先下载原视频',
|
||||
'lastFrame.errNoPicture': '该文件没有视频画面,无法导出尾帧',
|
||||
'lastFrame.errUnseekable': '无法定位到视频结尾(时长未知或来源不支持拖动进度),未导出尾帧',
|
||||
'lastFrame.errBlack': '视频结尾 1 秒内都是黑屏,未导出尾帧',
|
||||
'lastFrame.errEmpty': '浏览器未能解码出片尾画面,请重试或换用电脑端 Chrome / Edge',
|
||||
'lastFrame.errUnknown': '导出尾帧失败:{msg}',
|
||||
|
||||
// --- Artifact / canvas nodes ---
|
||||
'artifact.artifactLabel': '产物',
|
||||
@@ -1538,6 +1555,7 @@ export const zh: Dict = {
|
||||
'studio.slotMask': '遮罩',
|
||||
'studio.slotFirst': '首帧',
|
||||
'studio.slotLast': '尾帧',
|
||||
'studio.slotOptional': '可选',
|
||||
'studio.slotRefVideo': '参考视频',
|
||||
'studio.slotAudio': '参考音频',
|
||||
'studio.slotPick': '点击或拖入',
|
||||
@@ -1882,8 +1900,8 @@ export const zh: Dict = {
|
||||
'home.stageProgress': '五段进度',
|
||||
'tasks.sourceWorkbench': '创作流程',
|
||||
'jobst.idSuffix': ' · ComfyUI 任务 ID {id}',
|
||||
'jobst.done': '完成',
|
||||
'jobst.doneDetail': 'ComfyUI 已执行完成,结果已保存',
|
||||
'jobst.done': '定影',
|
||||
'jobst.doneDetail': '生成完成,结果已定影保存',
|
||||
'jobst.dryRun': '占位结果',
|
||||
'jobst.dryRunDetail': '占位结果:当前开启了 Dry-run,没有调用 ComfyUI,不是真实生成',
|
||||
'jobst.noOutput': '无产出',
|
||||
|
||||
@@ -0,0 +1,343 @@
|
||||
/**
|
||||
* 导出尾帧 (HEL-669): decode a frame just before the end of a video in the
|
||||
* browser and save it as a PNG at the video's native resolution.
|
||||
*
|
||||
* Frames are taken from a hidden, muted <video> of the same URL so the
|
||||
* player the user is watching never jumps. Media is served same-origin by
|
||||
* /api/file, so the canvas stays untainted.
|
||||
*
|
||||
* The pure helpers at the top touch no DOM and import nothing, so
|
||||
* scripts/check-export-frame.mjs can run them under plain Node.
|
||||
*/
|
||||
|
||||
export type FrameErrorCode =
|
||||
| "timeout"
|
||||
| "not-found"
|
||||
| "forbidden"
|
||||
| "network"
|
||||
| "decode"
|
||||
| "unsupported"
|
||||
| "cross-origin"
|
||||
| "no-picture"
|
||||
| "unseekable"
|
||||
| "black"
|
||||
| "empty";
|
||||
|
||||
export class FrameExportError extends Error {
|
||||
code: FrameErrorCode;
|
||||
|
||||
constructor(code: FrameErrorCode, detail?: string) {
|
||||
super(detail ? `${code}: ${detail}` : code);
|
||||
this.name = "FrameExportError";
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Seconds before the end to try, nearest first. The exact end is often not
|
||||
* decodable, so the first try is ~1 frame back; later tries step past a
|
||||
* black fade-out tail.
|
||||
*/
|
||||
export const TAIL_OFFSETS = [0.05, 0.12, 0.25, 0.5, 1];
|
||||
|
||||
export function tailSeekTimes(duration: number): number[] {
|
||||
if (!Number.isFinite(duration) || duration <= 0) return [0];
|
||||
const times: number[] = [];
|
||||
for (const off of TAIL_OFFSETS) {
|
||||
const t = Math.max(0, Math.round((duration - off) * 1000) / 1000);
|
||||
if (!times.includes(t)) times.push(t);
|
||||
}
|
||||
return times;
|
||||
}
|
||||
|
||||
/** File name of the video behind a media URL (`/api/file?path=…` or plain). */
|
||||
export function videoBaseName(src: string): string {
|
||||
let name = "";
|
||||
try {
|
||||
const url = new URL(src, "http://local.invalid/");
|
||||
const path =
|
||||
url.searchParams.get("path") ?? decodeURIComponent(url.pathname);
|
||||
name = path.split(/[\\/]/).pop() ?? "";
|
||||
} catch {
|
||||
name = "";
|
||||
}
|
||||
name = name.replace(/\.[a-z0-9]{1,5}$/i, "");
|
||||
name = name.replace(/[\\/:*?"<>|\u0000-\u001f]+/g, "_").trim();
|
||||
return name || "video";
|
||||
}
|
||||
|
||||
/** `{视频名}_{tag}_{秒}s.png` — names the source video and the frame time. */
|
||||
export function frameFileName(
|
||||
src: string,
|
||||
seconds: number,
|
||||
tag: string,
|
||||
): string {
|
||||
const safeTag = tag.replace(/[\\/:*?"<>|\s]+/g, "-");
|
||||
return `${videoBaseName(src)}_${safeTag}_${seconds.toFixed(3)}s.png`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Classify sampled RGBA pixels: "empty" when nothing was painted (the
|
||||
* decoder handed back no picture), "black" for an all-dark frame, else null.
|
||||
* A bright highlight anywhere keeps a dark scene from counting as black.
|
||||
*/
|
||||
export function blankKind(rgba: ArrayLike<number>): "empty" | "black" | null {
|
||||
let opaque = 0;
|
||||
let sum = 0;
|
||||
let max = 0;
|
||||
for (let i = 0; i + 3 < rgba.length; i += 4) {
|
||||
if (rgba[i + 3] < 8) continue;
|
||||
opaque++;
|
||||
const luma = 0.2126 * rgba[i] + 0.7152 * rgba[i + 1] + 0.0722 * rgba[i + 2];
|
||||
sum += luma;
|
||||
if (luma > max) max = luma;
|
||||
}
|
||||
if (opaque === 0) return "empty";
|
||||
// 16 = limited-range video black when a decoder skips range expansion.
|
||||
if (max < 40 && sum / opaque < 20) return "black";
|
||||
return null;
|
||||
}
|
||||
|
||||
/** HTTP status of a failed media fetch → error code (null = not decisive). */
|
||||
export function statusErrorCode(status: number): FrameErrorCode | null {
|
||||
if (status === 404 || status === 410) return "not-found";
|
||||
if (status === 401 || status === 403) return "forbidden";
|
||||
if (status >= 400) return "network";
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---- browser side -------------------------------------------------------
|
||||
|
||||
export interface LastFrame {
|
||||
blob: Blob;
|
||||
width: number;
|
||||
height: number;
|
||||
/** Media time of the exported frame, in seconds. */
|
||||
time: number;
|
||||
fileName: string;
|
||||
}
|
||||
|
||||
export interface CaptureOptions {
|
||||
/** Word placed in the file name, e.g. 尾帧. */
|
||||
fileTag: string;
|
||||
timeoutMs?: number;
|
||||
}
|
||||
|
||||
const SAMPLE = 64;
|
||||
|
||||
function isCrossOrigin(src: string): boolean {
|
||||
try {
|
||||
const url = new URL(src, location.href);
|
||||
if (url.protocol === "blob:" || url.protocol === "data:") return false;
|
||||
return url.origin !== location.origin;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Probe the URL so a failed load can say 不存在 / 无权限 / 跨域 precisely. */
|
||||
async function classifyLoadFailure(
|
||||
video: HTMLVideoElement,
|
||||
src: string,
|
||||
crossOrigin: boolean,
|
||||
): Promise<FrameExportError> {
|
||||
const ctl = new AbortController();
|
||||
const timer = setTimeout(() => ctl.abort(), 5000);
|
||||
try {
|
||||
const res = await fetch(src, {
|
||||
headers: { Range: "bytes=0-0" },
|
||||
mode: crossOrigin ? "cors" : "same-origin",
|
||||
signal: ctl.signal,
|
||||
});
|
||||
ctl.abort();
|
||||
const code = statusErrorCode(res.status);
|
||||
if (code) return new FrameExportError(code, `HTTP ${res.status}`);
|
||||
} catch {
|
||||
if (crossOrigin) return new FrameExportError("cross-origin");
|
||||
return new FrameExportError("network");
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
const mediaCode = video.error?.code;
|
||||
if (mediaCode === MediaError.MEDIA_ERR_NETWORK) {
|
||||
return new FrameExportError("network", video.error?.message);
|
||||
}
|
||||
if (mediaCode === MediaError.MEDIA_ERR_DECODE) {
|
||||
return new FrameExportError("decode", video.error?.message);
|
||||
}
|
||||
return new FrameExportError("unsupported", video.error?.message);
|
||||
}
|
||||
|
||||
export async function captureLastFrame(
|
||||
src: string,
|
||||
{ fileTag, timeoutMs = 30000 }: CaptureOptions,
|
||||
): Promise<LastFrame> {
|
||||
const crossOrigin = isCrossOrigin(src);
|
||||
const video = document.createElement("video");
|
||||
if (crossOrigin) video.crossOrigin = "anonymous";
|
||||
video.muted = true;
|
||||
video.playsInline = true;
|
||||
video.preload = "auto";
|
||||
video.setAttribute("aria-hidden", "true");
|
||||
// Kept in the DOM (some engines never paint a detached video) but unseen.
|
||||
Object.assign(video.style, {
|
||||
position: "fixed",
|
||||
left: "0",
|
||||
top: "0",
|
||||
width: "1px",
|
||||
height: "1px",
|
||||
opacity: "0",
|
||||
pointerEvents: "none",
|
||||
});
|
||||
document.body.appendChild(video);
|
||||
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
|
||||
/** Resolve on `event`; reject on a media error or the shared deadline. */
|
||||
const until = (event: string) =>
|
||||
new Promise<void>((resolve, reject) => {
|
||||
const done = (fn: () => void) => {
|
||||
clearTimeout(timer);
|
||||
video.removeEventListener(event, onEvent);
|
||||
video.removeEventListener("error", onError);
|
||||
fn();
|
||||
};
|
||||
const onEvent = () => done(resolve);
|
||||
const onError = () =>
|
||||
done(() => {
|
||||
classifyLoadFailure(video, src, crossOrigin).then(reject, reject);
|
||||
});
|
||||
const timer = setTimeout(
|
||||
() => done(() => reject(new FrameExportError("timeout"))),
|
||||
Math.max(0, deadline - Date.now()),
|
||||
);
|
||||
video.addEventListener(event, onEvent);
|
||||
video.addEventListener("error", onError);
|
||||
});
|
||||
|
||||
const seek = async (time: number) => {
|
||||
const settled = until("seeked");
|
||||
video.currentTime = time;
|
||||
await settled;
|
||||
};
|
||||
|
||||
/** Wait until the seeked frame has actually been decoded and presented. */
|
||||
const presented = () =>
|
||||
new Promise<void>((resolve) => {
|
||||
const fallback = setTimeout(resolve, 250);
|
||||
const finish = () => {
|
||||
clearTimeout(fallback);
|
||||
resolve();
|
||||
};
|
||||
if (typeof video.requestVideoFrameCallback === "function") {
|
||||
video.requestVideoFrameCallback(() => finish());
|
||||
} else {
|
||||
requestAnimationFrame(() => requestAnimationFrame(finish));
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
const metadata = until("loadedmetadata");
|
||||
video.src = src;
|
||||
video.load();
|
||||
await metadata;
|
||||
|
||||
if (!video.videoWidth || !video.videoHeight) {
|
||||
throw new FrameExportError("no-picture");
|
||||
}
|
||||
|
||||
// MediaRecorder WebM reports Infinity until the end has been read. When
|
||||
// the server cannot seek either, the end is unreachable — fail rather
|
||||
// than hand back the first frame.
|
||||
let duration = video.duration;
|
||||
if (!Number.isFinite(duration) || duration <= 0) {
|
||||
await seek(1e101);
|
||||
duration = video.duration;
|
||||
if (!Number.isFinite(duration) || duration <= 0) {
|
||||
throw new FrameExportError("unseekable", "duration unknown");
|
||||
}
|
||||
}
|
||||
|
||||
const width = video.videoWidth;
|
||||
const height = video.videoHeight;
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
const ctx = canvas.getContext("2d");
|
||||
const sample = document.createElement("canvas");
|
||||
sample.width = SAMPLE;
|
||||
sample.height = SAMPLE;
|
||||
const sampleCtx = sample.getContext("2d", { willReadFrequently: true });
|
||||
if (!ctx || !sampleCtx)
|
||||
throw new FrameExportError("empty", "no 2d context");
|
||||
|
||||
let lastBlank: "empty" | "black" = "empty";
|
||||
for (const time of tailSeekTimes(duration)) {
|
||||
await seek(time);
|
||||
if (video.readyState < HTMLMediaElement.HAVE_CURRENT_DATA) {
|
||||
// iOS Safari only decodes after a play(); muted inline play is allowed.
|
||||
await video.play().catch(() => {});
|
||||
video.pause();
|
||||
await seek(time);
|
||||
}
|
||||
if (Math.abs(video.currentTime - time) > 0.5) {
|
||||
throw new FrameExportError(
|
||||
"unseekable",
|
||||
`asked ${time}s, landed at ${video.currentTime}s`,
|
||||
);
|
||||
}
|
||||
await presented();
|
||||
|
||||
ctx.clearRect(0, 0, width, height);
|
||||
ctx.drawImage(video, 0, 0, width, height);
|
||||
sampleCtx.clearRect(0, 0, SAMPLE, SAMPLE);
|
||||
sampleCtx.drawImage(canvas, 0, 0, SAMPLE, SAMPLE);
|
||||
let pixels: Uint8ClampedArray;
|
||||
try {
|
||||
pixels = sampleCtx.getImageData(0, 0, SAMPLE, SAMPLE).data;
|
||||
} catch (err) {
|
||||
throw new FrameExportError("cross-origin", String(err));
|
||||
}
|
||||
const blank = blankKind(pixels);
|
||||
if (blank) {
|
||||
lastBlank = blank;
|
||||
continue;
|
||||
}
|
||||
|
||||
const blob = await new Promise<Blob | null>((resolve) => {
|
||||
try {
|
||||
canvas.toBlob(resolve, "image/png");
|
||||
} catch {
|
||||
resolve(null);
|
||||
}
|
||||
});
|
||||
if (!blob) throw new FrameExportError("empty", "toBlob returned nothing");
|
||||
const shown = video.currentTime;
|
||||
return {
|
||||
blob,
|
||||
width,
|
||||
height,
|
||||
time: shown,
|
||||
fileName: frameFileName(src, shown, fileTag),
|
||||
};
|
||||
}
|
||||
throw new FrameExportError(lastBlank);
|
||||
} finally {
|
||||
video.removeAttribute("src");
|
||||
video.load();
|
||||
video.remove();
|
||||
}
|
||||
}
|
||||
|
||||
export function downloadBlob(blob: Blob, fileName: string): void {
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = fileName;
|
||||
a.rel = "noopener";
|
||||
a.style.display = "none";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import { t } from "$lib/i18n.svelte";
|
||||
import { toast } from "$lib/toast";
|
||||
import {
|
||||
captureLastFrame,
|
||||
downloadBlob,
|
||||
FrameExportError,
|
||||
type FrameErrorCode,
|
||||
} from "./exportFrame";
|
||||
|
||||
const ERROR_KEYS: Record<FrameErrorCode, string> = {
|
||||
timeout: "lastFrame.errTimeout",
|
||||
"not-found": "lastFrame.errNotFound",
|
||||
forbidden: "lastFrame.errForbidden",
|
||||
network: "lastFrame.errNetwork",
|
||||
decode: "lastFrame.errDecode",
|
||||
unsupported: "lastFrame.errUnsupported",
|
||||
"cross-origin": "lastFrame.errCrossOrigin",
|
||||
"no-picture": "lastFrame.errNoPicture",
|
||||
unseekable: "lastFrame.errUnseekable",
|
||||
black: "lastFrame.errBlack",
|
||||
empty: "lastFrame.errEmpty",
|
||||
};
|
||||
|
||||
/**
|
||||
* 导出尾帧 for one video URL: capture, download the PNG and report the
|
||||
* outcome as a toast. Never throws. Resolves true when a file was saved.
|
||||
*/
|
||||
export async function exportLastFrame(src: string): Promise<boolean> {
|
||||
try {
|
||||
const frame = await captureLastFrame(src, {
|
||||
fileTag: t("lastFrame.fileTag"),
|
||||
});
|
||||
downloadBlob(frame.blob, frame.fileName);
|
||||
toast.success(
|
||||
t("lastFrame.done", {
|
||||
name: frame.fileName,
|
||||
size: `${frame.width}×${frame.height}`,
|
||||
}),
|
||||
);
|
||||
return true;
|
||||
} catch (err) {
|
||||
if (err instanceof FrameExportError) {
|
||||
toast.error(t(ERROR_KEYS[err.code]), 6000);
|
||||
} else {
|
||||
const msg = err instanceof Error ? err.message : String(err);
|
||||
toast.error(t("lastFrame.errUnknown", { msg }), 6000);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -589,6 +589,11 @@
|
||||
function avatarStyle(n: number): string {
|
||||
return `var(--avatar-${Math.min(Math.max(n, 1), 5)})`;
|
||||
}
|
||||
|
||||
// HEL-680 灰阶头像:1–2 亮阶配深字,3–5 暗阶配浅字,按阶数决定。
|
||||
function avatarLight(n: number | undefined): boolean {
|
||||
return Math.min(Math.max(n ?? 1, 1), 5) <= 2;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#snippet skillRow(skill: SkillAdminEntry, detail: string)}
|
||||
@@ -655,7 +660,7 @@
|
||||
class:selected
|
||||
onclick={() => selectAgent(agent.key)}
|
||||
>
|
||||
<span class="avatar" class:dark={agent.avatar_dark} style:background={avatarStyle(agent.avatar)}>
|
||||
<span class="avatar" class:dark={avatarLight(agent.avatar)} style:background={avatarStyle(agent.avatar)}>
|
||||
{agent.char}
|
||||
</span>
|
||||
<span class="agent-meta">
|
||||
@@ -693,7 +698,7 @@
|
||||
<section class="mid">
|
||||
{#if activeAgent}
|
||||
<header class="chat-head">
|
||||
<span class="avatar lg" class:dark={activeAgent.avatar_dark} style:background={avatarStyle(activeAgent.avatar)}>
|
||||
<span class="avatar lg" class:dark={avatarLight(activeAgent.avatar)} style:background={avatarStyle(activeAgent.avatar)}>
|
||||
{activeAgent.char}
|
||||
</span>
|
||||
<div class="chat-head-meta">
|
||||
|
||||
+181
-59
@@ -4,62 +4,67 @@
|
||||
|
||||
:root {
|
||||
/* ------------------------------------------------------------------
|
||||
* 融合视觉 design tokens — HEL-649 整站施工规范 §一(流水台结构 ×
|
||||
* 放映厅配色)。Single source of truth for the whole app: pages and
|
||||
* components reference these variables only — no hardcoded colors,
|
||||
* no ad-hoc overrides. Gold is for key actions and the current
|
||||
* selection only; status colors each carry exactly one meaning.
|
||||
* 无彩灰阶 design tokens — HEL-680 S1(白栖知 theme-1「暗房放大机」
|
||||
* × HEL-679 已确认融合样稿)。Single source of truth for the whole
|
||||
* app: pages and components reference these variables only — no
|
||||
* hardcoded colors, no ad-hoc overrides. 界面只有暖调黑白灰,作品是
|
||||
* 屏幕上唯一成片的颜色;状态色仅按主题卡的两处有限例外(琥珀
|
||||
* #A3915F、红 #B3564A)使用,不放大成全站主色。选中=取景框角线,
|
||||
* 完成=「定影」,结果=相纸白边。
|
||||
* ------------------------------------------------------------------ */
|
||||
|
||||
/* 底色:蓝黑四阶,逐层浮起 (§1.1) */
|
||||
--bg: #07090e;
|
||||
--bg-2: #0c0f16;
|
||||
--bg-3: #121724;
|
||||
--bg-4: #1a2133;
|
||||
--line: #1b2233;
|
||||
--line-2: #2a3450;
|
||||
--page-glow: radial-gradient(1200px 500px at 70% -10%, rgba(38, 52, 92, 0.25), transparent 60%);
|
||||
--float-bg: linear-gradient(180deg, #10152a, var(--bg-2));
|
||||
--overlay: rgba(4, 6, 10, 0.6);
|
||||
--media-scrim: rgba(7, 9, 14, 0.65);
|
||||
/* 底色:显影灰阶四阶,逐层浮起(theme-1:#212120 底 / #2C2C2A 面板) */
|
||||
--bg: #212120;
|
||||
--bg-2: #262625;
|
||||
--bg-3: #2c2c2a;
|
||||
--bg-4: #383835;
|
||||
--line: #313130;
|
||||
--line-2: #454542;
|
||||
--page-glow: radial-gradient(1200px 500px at 70% -10%, rgba(245, 244, 238, 0.035), transparent 60%);
|
||||
--float-bg: linear-gradient(180deg, #2e2e2c, var(--bg-2));
|
||||
--overlay: rgba(18, 18, 17, 0.62);
|
||||
--media-scrim: rgba(18, 18, 17, 0.66);
|
||||
--on-media: #fff;
|
||||
--on-media-line: rgba(255, 255, 255, 0.05);
|
||||
--composer-bg: linear-gradient(180deg, #0e1220, var(--bg-2));
|
||||
--composer-focus: 0 0 0 1px rgba(242, 199, 132, 0.12), 0 8px 28px rgba(0, 0, 0, 0.4);
|
||||
--composer-bg: linear-gradient(180deg, #2a2a28, var(--bg-2));
|
||||
--composer-focus: 0 0 0 1px rgba(245, 244, 238, 0.12), 0 8px 28px rgba(0, 0, 0, 0.4);
|
||||
|
||||
/* 放映金:主按钮、当前选中、改过的参数、聚焦框、Toast 动作 (§1.2) */
|
||||
--accent: #f2c784;
|
||||
--accent-ink: #23170a;
|
||||
--accent-soft: rgba(242, 199, 132, 0.13);
|
||||
--accent-hi: #f7d9a2;
|
||||
--accent-lo: #ecaf63;
|
||||
--accent-glow: rgba(236, 175, 99, 0.28);
|
||||
--accent-line: rgba(242, 199, 132, 0.55);
|
||||
/* 相纸白(重点色):主按钮、当前选中、改过的参数、聚焦框、Toast 动作
|
||||
(theme-1 #F5F4EE 重点) */
|
||||
--accent: #f5f4ee;
|
||||
--accent-ink: #212120;
|
||||
--accent-soft: rgba(245, 244, 238, 0.08);
|
||||
--accent-hi: #ffffff;
|
||||
--accent-lo: #ddddd7;
|
||||
--accent-glow: rgba(240, 239, 233, 0.2);
|
||||
--accent-line: rgba(245, 244, 238, 0.55);
|
||||
--accent-grad: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
|
||||
--accent-grad-hover: linear-gradient(180deg, #fbe3b6, #f0b968);
|
||||
--accent-ring: 0 0 0 1px rgba(242, 199, 132, 0.7), 0 0 22px var(--accent-glow);
|
||||
--btn-glow: 0 2px 14px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
|
||||
--btn-glow-hover: 0 4px 18px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, 0.4);
|
||||
--accent-wash: linear-gradient(180deg, rgba(242, 199, 132, 0.05), transparent 40%);
|
||||
--sel-shadow: 0 0 0 1px rgba(242, 199, 132, 0.15), 0 6px 24px rgba(0, 0, 0, 0.35);
|
||||
--accent-grad-hover: linear-gradient(180deg, #ffffff, #e8e7df);
|
||||
--accent-ring: 0 0 0 1px rgba(245, 244, 238, 0.7), 0 0 22px var(--accent-glow);
|
||||
--btn-glow: 0 2px 10px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.55);
|
||||
--btn-glow-hover: 0 3px 14px rgba(0, 0, 0, 0.44), inset 0 1px 0 rgba(255, 255, 255, 0.65);
|
||||
--accent-wash: linear-gradient(180deg, rgba(245, 244, 238, 0.05), transparent 40%);
|
||||
--sel-shadow: 0 0 0 1px rgba(245, 244, 238, 0.14), 0 6px 24px rgba(0, 0, 0, 0.35);
|
||||
|
||||
/* 信号色:绿=完成/已确认/通过,青=进行中/在线,红=失败/危险,
|
||||
琥珀=待确认/文件缺失/限额 (§1.3) */
|
||||
--ok: #49cb90;
|
||||
--ok-soft: rgba(73, 203, 144, 0.13);
|
||||
--run: #54dfd2;
|
||||
--run-soft: rgba(84, 223, 210, 0.13);
|
||||
--run-grad: linear-gradient(90deg, #3bbfb4, var(--run));
|
||||
--err: #f0645a;
|
||||
--err-soft: rgba(240, 100, 90, 0.13);
|
||||
--err-line: rgba(240, 100, 90, 0.6);
|
||||
--warn: #f0b45c;
|
||||
--warn-soft: rgba(240, 180, 92, 0.13);
|
||||
/* 信号色:完成=显影亮灰(「定影」,配图标/文字双编码),进行中=灰阶
|
||||
+动效;红/琥珀只按 theme-1 卡片的有限例外使用(红=失败/危险
|
||||
#B3564A 系,琥珀=待确认/文件缺失 #A3915F) */
|
||||
--ok: #ddddd7;
|
||||
--ok-soft: rgba(221, 221, 215, 0.1);
|
||||
--run: #b8b6ac;
|
||||
--run-soft: rgba(184, 182, 172, 0.12);
|
||||
--run-grad: linear-gradient(90deg, #8f8e85, #c6c5c0);
|
||||
--err: #d07a6b;
|
||||
--err-solid: #b3564a;
|
||||
--err-soft: rgba(181, 86, 74, 0.15);
|
||||
--err-line: rgba(208, 122, 107, 0.55);
|
||||
--warn: #a3915f;
|
||||
--warn-soft: rgba(163, 145, 95, 0.13);
|
||||
|
||||
/* 文字与字体 (§1.4);--text-2 是深底可读性下限,不得再暗 */
|
||||
--text: #f4f6fa;
|
||||
--text-2: #aab2c5;
|
||||
--text-3: #6d7690;
|
||||
/* 文字与字体;--text-3 是深底可读性下限(≥4.5:1 on --bg-3),不得再暗 */
|
||||
--text: #f0efe9;
|
||||
--text-2: #a8a69c;
|
||||
--text-3: #94938c;
|
||||
--font: 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', system-ui, sans-serif;
|
||||
--mono: 'JetBrains Mono', ui-monospace, monospace;
|
||||
--fs-title: 15px;
|
||||
@@ -95,8 +100,14 @@
|
||||
/* 专属符号 (§1.7):齿孔只在记录流/输入台分隔带,光晕只在播放舞台 */
|
||||
--sprocket: radial-gradient(circle 2px, var(--line-2) 98%, transparent);
|
||||
--stage-bg:
|
||||
radial-gradient(60% 45% at 50% 38%, rgba(242, 199, 132, 0.07), transparent 70%),
|
||||
radial-gradient(80% 70% at 50% 50%, #0d1220, #05070c);
|
||||
radial-gradient(60% 45% at 50% 38%, rgba(245, 244, 238, 0.045), transparent 70%),
|
||||
radial-gradient(80% 70% at 50% 50%, #232322, #171716);
|
||||
|
||||
/* 取景框角线与相纸白边 (HEL-680):内容级选中/结果呈现的统一语言 */
|
||||
--frame-w: 2px;
|
||||
--frame-arm: 12px;
|
||||
--frame-inset: -4px;
|
||||
--paper-w: 4px;
|
||||
|
||||
/* 动效 (§1.6,取 HEL-648 实测值);只动 transform / opacity */
|
||||
--ease-out: cubic-bezier(0.23, 1, 0.32, 1);
|
||||
@@ -113,13 +124,13 @@
|
||||
--d-progress: 400ms;
|
||||
--press-scale: 0.97;
|
||||
|
||||
/* Avatar five-color set — five agents only; the one colorful gradient
|
||||
family the spec keeps (§3.6). */
|
||||
--avatar-1: linear-gradient(135deg, #e8a33d, #b96a1b);
|
||||
--avatar-2: linear-gradient(135deg, #5b8def, #3a5fa9);
|
||||
--avatar-3: linear-gradient(135deg, #3fb97f, #2a7a54);
|
||||
--avatar-4: linear-gradient(135deg, #b98be0, #7a4fa9);
|
||||
--avatar-5: linear-gradient(135deg, #d98e6a, #a95535);
|
||||
/* Avatar five-step grayscale (HEL-680 无彩化):1–2 亮阶配深字,
|
||||
3–5 暗阶配浅字;仍是五个身份位,只是从彩色渐变改为显影灰阶。 */
|
||||
--avatar-1: linear-gradient(135deg, #e8e7df, #cdcbc4);
|
||||
--avatar-2: linear-gradient(135deg, #b5b3aa, #9c9a91);
|
||||
--avatar-3: linear-gradient(135deg, #6b6a66, #55544f);
|
||||
--avatar-4: linear-gradient(135deg, #55544f, #424140);
|
||||
--avatar-5: linear-gradient(135deg, #424140, #2e2e2c);
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
* Legacy token names (§六 映射表) — aliases only, never new values,
|
||||
@@ -297,7 +308,7 @@ code,
|
||||
color: var(--err);
|
||||
}
|
||||
.a-btn.danger-solid {
|
||||
background: var(--err);
|
||||
background: var(--err-solid);
|
||||
color: var(--on-media);
|
||||
}
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
@@ -550,11 +561,47 @@ button.status-chip:active {
|
||||
.a-chip.changed {
|
||||
color: var(--accent);
|
||||
}
|
||||
/* Selected filter chip (§3.5 筛选芯片组): 当前选中 = 金色文字 + accent-soft 底 */
|
||||
/* Selected filter chip (§3.5 筛选芯片组): 当前选中 = 取景框角线缩影 +
|
||||
相纸白文字 + accent-soft 底 (HEL-680) */
|
||||
.a-chip.sel {
|
||||
position: relative;
|
||||
background: var(--accent-soft);
|
||||
color: var(--accent);
|
||||
}
|
||||
.a-chip.sel::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 2px;
|
||||
pointer-events: none;
|
||||
background-image:
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0);
|
||||
background-position:
|
||||
left top,
|
||||
left top,
|
||||
right top,
|
||||
right top,
|
||||
left bottom,
|
||||
left bottom,
|
||||
right bottom,
|
||||
right bottom;
|
||||
background-size:
|
||||
6px 1.5px,
|
||||
1.5px 6px,
|
||||
6px 1.5px,
|
||||
1.5px 6px,
|
||||
6px 1.5px,
|
||||
1.5px 6px,
|
||||
6px 1.5px,
|
||||
1.5px 6px;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.a-chip.warn {
|
||||
color: var(--warn);
|
||||
}
|
||||
@@ -753,6 +800,81 @@ button.a-tile:disabled {
|
||||
box-shadow: 0 0 0 1px var(--line);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
* 取景框角线选中 (HEL-680):内容级选中态的唯一语言——四角短线取景,
|
||||
* 不整框描边。挂在需要角线的元素上(元素自身可 overflow 可见;被
|
||||
* overflow:hidden 裁切的容器改用 --frame-inset 正值画在内侧)。
|
||||
* ------------------------------------------------------------------ */
|
||||
.a-frame {
|
||||
position: relative;
|
||||
}
|
||||
.a-frame::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: var(--frame-inset, -4px);
|
||||
z-index: 3;
|
||||
pointer-events: none;
|
||||
background-image:
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0),
|
||||
linear-gradient(var(--accent) 0 0);
|
||||
background-position:
|
||||
left top,
|
||||
left top,
|
||||
right top,
|
||||
right top,
|
||||
left bottom,
|
||||
left bottom,
|
||||
right bottom,
|
||||
right bottom;
|
||||
background-size:
|
||||
var(--frame-arm, 12px) var(--frame-w, 2px),
|
||||
var(--frame-w, 2px) var(--frame-arm, 12px),
|
||||
var(--frame-arm, 12px) var(--frame-w, 2px),
|
||||
var(--frame-w, 2px) var(--frame-arm, 12px),
|
||||
var(--frame-arm, 12px) var(--frame-w, 2px),
|
||||
var(--frame-w, 2px) var(--frame-arm, 12px),
|
||||
var(--frame-arm, 12px) var(--frame-w, 2px),
|
||||
var(--frame-w, 2px) var(--frame-arm, 12px);
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
/* 相纸白边 (HEL-680):结果媒体外的相纸白框,底边略厚如手工相纸。
|
||||
挂在承载 img/video 的媒体容器上;容器尺寸由调用方决定。 */
|
||||
.a-photo {
|
||||
background: var(--accent);
|
||||
border: var(--paper-w, 4px) solid var(--accent);
|
||||
border-bottom-width: calc(var(--paper-w, 4px) + 2px);
|
||||
border-radius: 2px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 「定影」完成章 (HEL-680):已定影结果右上角的完成印记,随 jobst.done
|
||||
文案走(中文=定影)。absolute 定位,挂在有媒体的结果容器内。 */
|
||||
.a-fix {
|
||||
position: absolute;
|
||||
top: var(--sp-3);
|
||||
right: var(--sp-3);
|
||||
z-index: 2;
|
||||
padding: 1px 6px;
|
||||
border: 1px solid currentColor;
|
||||
border-radius: 3px;
|
||||
background: var(--media-scrim);
|
||||
color: var(--ok);
|
||||
font-size: var(--fs-mini);
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.1em;
|
||||
text-indent: 0.1em;
|
||||
transform: rotate(-4deg);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Floating surface for pop / drawer / confirm / toast / lightbox (§四.3). */
|
||||
.a-float {
|
||||
background: var(--float-bg);
|
||||
|
||||
@@ -209,7 +209,13 @@
|
||||
{:else}
|
||||
<div class="grid">
|
||||
{#each visible as item (item.path)}
|
||||
<div class="card" class:selected={selected.has(item.path)}>
|
||||
<div
|
||||
class="card"
|
||||
class:selected={selected.has(item.path)}
|
||||
class:a-frame={selected.has(item.path)}
|
||||
style:--frame-inset="3px"
|
||||
style:--frame-arm="16px"
|
||||
>
|
||||
<label class="check">
|
||||
<input
|
||||
type="checkbox"
|
||||
@@ -217,12 +223,12 @@
|
||||
onchange={() => toggle(item.path)}
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
type="button"
|
||||
class="media"
|
||||
onclick={() => openPreview(item)}
|
||||
title={item.name}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="media a-photo"
|
||||
onclick={() => openPreview(item)}
|
||||
title={item.name}
|
||||
>
|
||||
<SafeMedia src={assetUrl(item.path)} kind={item.kind} alt={item.name} controls={false} />
|
||||
</button>
|
||||
<div class="meta">
|
||||
@@ -341,7 +347,6 @@
|
||||
transition: border-color var(--d-state) ease;
|
||||
}
|
||||
.card.selected {
|
||||
border-color: var(--accent-line);
|
||||
background: linear-gradient(180deg, var(--accent-soft), transparent 32%), var(--bg-2);
|
||||
}
|
||||
.card :global(.media-el) {
|
||||
@@ -380,6 +385,14 @@
|
||||
cursor: zoom-in;
|
||||
overflow: hidden;
|
||||
}
|
||||
/* 相纸白边 (HEL-680):素材墙里的作品按相纸呈现 */
|
||||
.media.a-photo {
|
||||
border: var(--paper-w, 4px) solid var(--accent);
|
||||
border-bottom-width: calc(var(--paper-w, 4px) + 2px);
|
||||
background: var(--accent);
|
||||
border-radius: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.media :global(img),
|
||||
.media :global(video) {
|
||||
width: 100%;
|
||||
|
||||
@@ -392,14 +392,8 @@
|
||||
char: string;
|
||||
dark?: boolean;
|
||||
}[] = [
|
||||
{
|
||||
role: 'story',
|
||||
labelKey: 'models.agentStory',
|
||||
color: 'var(--avatar-1)',
|
||||
char: '剧',
|
||||
dark: true,
|
||||
},
|
||||
{ role: 'style', labelKey: 'models.agentStyle', color: 'var(--avatar-2)', char: '视' },
|
||||
{ role: 'story', labelKey: 'models.agentStory', color: 'var(--avatar-1)', char: '剧', dark: true },
|
||||
{ role: 'style', labelKey: 'models.agentStyle', color: 'var(--avatar-2)', char: '视', dark: true },
|
||||
{ role: 'script', labelKey: 'models.agentScript', color: 'var(--avatar-3)', char: '分' },
|
||||
{ role: 'assets', labelKey: 'models.agentAssets', color: 'var(--avatar-4)', char: '素' },
|
||||
{ role: 'video', labelKey: 'models.agentVideo', color: 'var(--avatar-5)', char: '镜' },
|
||||
|
||||
@@ -496,7 +496,11 @@
|
||||
<aside class="side-col">
|
||||
{#if currentAgent}
|
||||
<div class="side-card agent-card">
|
||||
<span class="agent-avatar" style:background={`var(--avatar-${currentAgent.avatar})`}>
|
||||
<span
|
||||
class="agent-avatar"
|
||||
class:light={(currentAgent.avatar ?? 1) <= 2}
|
||||
style:background={`var(--avatar-${currentAgent.avatar})`}
|
||||
>
|
||||
{currentAgent.char}
|
||||
</span>
|
||||
<div class="agent-copy">
|
||||
@@ -740,6 +744,10 @@
|
||||
color: var(--text);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
/* HEL-680 灰阶头像:1–2 亮阶用深字 */
|
||||
.agent-avatar.light {
|
||||
color: var(--accent-ink);
|
||||
}
|
||||
.agent-copy {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
+6
-2
@@ -11,6 +11,8 @@ Mode file e2e/fake_mode.json:
|
||||
can be driven all-green (every class present) or missing-node (catalogue
|
||||
omits classes). Absent → {} (every node "missing").
|
||||
- no_outputs: history entries complete with no files (test-run no-output pass)
|
||||
- video_file: absolute path of an mp4 served (and named) as the video output
|
||||
instead of tiny.mp4 (HEL-669 last-frame export runs real clips through it)
|
||||
"""
|
||||
from __future__ import annotations
|
||||
import json, threading, uuid
|
||||
@@ -64,7 +66,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
return
|
||||
if self.path.startswith("/view"):
|
||||
if "fmt=mp4" in self.path or ".mp4" in self.path:
|
||||
self._raw(200, MP4.read_bytes(), "video/mp4")
|
||||
src = read_mode().get("video_file")
|
||||
self._raw(200, Path(src).read_bytes() if src else MP4.read_bytes(), "video/mp4")
|
||||
else:
|
||||
self._raw(200, PNG_1PX, "image/png")
|
||||
return
|
||||
@@ -82,7 +85,8 @@ class Handler(BaseHTTPRequestHandler):
|
||||
self.server.accepted.append(pid)
|
||||
videos = mode.get("videos") is True
|
||||
no_outputs = mode.get("no_outputs") is True
|
||||
out_name = "out-1.mp4" if videos else "out-1.png"
|
||||
video_file = mode.get("video_file")
|
||||
out_name = (Path(video_file).stem + ".mp4" if video_file else "out-1.mp4") if videos else "out-1.png"
|
||||
key = "videos" if videos else "images"
|
||||
outputs = {} if no_outputs else {
|
||||
self._output_node(body): {key: [{"filename": out_name, "subfolder": "", "type": "output"}]}
|
||||
|
||||
@@ -0,0 +1,450 @@
|
||||
/* HEL-669 导出尾帧 browser validation against the isolated stack:
|
||||
* vite dev (5173) → backend (8247) → fake ComfyUI (18188), seeded by seed.py.
|
||||
*
|
||||
* node e2e/lastframe.mjs [dir-with-real-generated-mp4s]
|
||||
*
|
||||
* Every clip reaches the UI through the normal generate → worker download
|
||||
* path (fake ComfyUI serves it via the `video_file` mode). Real clips come
|
||||
* from the optional directory; portrait / square / black-tail / all-black /
|
||||
* WebM clips are synthesised in the browser with MediaRecorder.
|
||||
* Prints PASS/FAIL per check; exported PNGs + screenshots go to
|
||||
* e2e/shots/lastframe/. */
|
||||
import { chromium } from 'playwright';
|
||||
import { spawn } from 'node:child_process';
|
||||
import crypto from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
const ROOT = path.dirname(fileURLToPath(import.meta.url));
|
||||
const OUT = path.join(ROOT, 'shots', 'lastframe');
|
||||
const SAMPLES = path.join(OUT, 'samples');
|
||||
fs.mkdirSync(SAMPLES, { recursive: true });
|
||||
|
||||
const API = 'http://127.0.0.1:8247';
|
||||
const WEB = 'http://127.0.0.1:5173';
|
||||
const MODE_FILE = path.join(ROOT, 'fake_mode.json');
|
||||
const REAL_DIR = process.argv[2] ? path.resolve(process.argv[2]) : null;
|
||||
|
||||
let failures = 0;
|
||||
function ok(name, cond, extra = '') {
|
||||
console.log(`${cond ? 'PASS' : 'FAIL'} ${name}${extra ? ' — ' + extra : ''}`);
|
||||
if (!cond) failures++;
|
||||
}
|
||||
|
||||
const api = async (p, init) => {
|
||||
const r = await fetch(API + p, { headers: { 'Content-Type': 'application/json' }, ...init });
|
||||
return r.json();
|
||||
};
|
||||
const fileUrl = (p) => `/api/file?path=${encodeURIComponent(p)}`;
|
||||
const sha = (p) => crypto.createHash('sha256').update(fs.readFileSync(p)).digest('hex');
|
||||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
/** Generate a studio video job whose output is `file`; returns the saved asset path. */
|
||||
async function generateWith(file, prompt) {
|
||||
fs.writeFileSync(MODE_FILE, JSON.stringify({ mode: 'ok', delay_sec: 0, videos: true, video_file: file }));
|
||||
const r = await api('/api/playground/generate', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ workflow_id: 2, input_values: { 1: prompt, 2: 6 }, source: 'studio-video' }),
|
||||
});
|
||||
const id = r.job.id;
|
||||
for (let i = 0; i < 150; i++) {
|
||||
const j = (await api('/api/playground/jobs')).find((x) => x.id === id);
|
||||
if (j?.status === 'done') return j.output_paths[0];
|
||||
if (j?.status === 'failed') throw new Error(`job ${id} failed: ${j.error}`);
|
||||
await sleep(200);
|
||||
}
|
||||
throw new Error(`job ${id} timed out`);
|
||||
}
|
||||
|
||||
/** PNG width/height from the IHDR chunk. */
|
||||
function pngSize(buf) {
|
||||
const sig = buf.subarray(0, 8).toString('hex') === '89504e470d0a1a0a';
|
||||
return sig ? { w: buf.readUInt32BE(16), h: buf.readUInt32BE(20) } : null;
|
||||
}
|
||||
|
||||
/** Browser-side: synthesise a clip; returns base64 bytes. */
|
||||
async function synth(page, spec) {
|
||||
return page.evaluate(async ({ w, h, seconds, fps, mime, mode }) => {
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = w;
|
||||
canvas.height = h;
|
||||
const ctx = canvas.getContext('2d');
|
||||
const total = Math.round(seconds * fps);
|
||||
const paint = (i) => {
|
||||
const left = (total - i) / fps;
|
||||
if (mode === 'allblack' || (mode === 'fadeblack' && left <= 0.4)) ctx.fillStyle = '#000';
|
||||
else if (mode === 'marker' && left <= 0.5) ctx.fillStyle = '#d0208c';
|
||||
else ctx.fillStyle = mode === 'fadeblack' ? '#e08a1e' : '#00b4c8';
|
||||
ctx.fillRect(0, 0, w, h);
|
||||
if (mode !== 'allblack' && !(mode === 'fadeblack' && left <= 0.4)) {
|
||||
ctx.fillStyle = '#fff';
|
||||
ctx.fillRect(((i * 7) % w) | 0, (h / 3) | 0, (w / 10) | 0, (h / 10) | 0);
|
||||
ctx.font = `${(h / 12) | 0}px sans-serif`;
|
||||
ctx.fillText(`#${i}`, 12, h - 24);
|
||||
}
|
||||
};
|
||||
paint(0);
|
||||
const stream = canvas.captureStream(fps);
|
||||
const rec = new MediaRecorder(stream, { mimeType: mime, videoBitsPerSecond: 4e6 });
|
||||
const chunks = [];
|
||||
rec.ondataavailable = (e) => e.data.size && chunks.push(e.data);
|
||||
const stopped = new Promise((r) => (rec.onstop = r));
|
||||
rec.start(100);
|
||||
for (let i = 0; i < total; i++) {
|
||||
paint(i);
|
||||
await new Promise((r) => setTimeout(r, 1000 / fps));
|
||||
}
|
||||
await new Promise((r) => setTimeout(r, 150));
|
||||
rec.stop();
|
||||
await stopped;
|
||||
const buf = new Uint8Array(await new Blob(chunks).arrayBuffer());
|
||||
let s = '';
|
||||
for (let i = 0; i < buf.length; i += 0x8000) s += String.fromCharCode(...buf.subarray(i, i + 0x8000));
|
||||
return btoa(s);
|
||||
}, spec);
|
||||
}
|
||||
|
||||
/** Browser-side: stats of a PNG + the frame an independent player shows at `at`. */
|
||||
async function inspectPng(page, b64, src, at) {
|
||||
return page.evaluate(
|
||||
async ({ b64, src, at }) => {
|
||||
const S = 64;
|
||||
const grab = (el) => {
|
||||
const c = document.createElement('canvas');
|
||||
c.width = S;
|
||||
c.height = S;
|
||||
const x = c.getContext('2d');
|
||||
x.drawImage(el, 0, 0, S, S);
|
||||
return x.getImageData(0, 0, S, S).data;
|
||||
};
|
||||
const img = new Image();
|
||||
img.src = `data:image/png;base64,${b64}`;
|
||||
await img.decode();
|
||||
const a = grab(img);
|
||||
let sum = 0;
|
||||
for (let i = 0; i < a.length; i += 4) sum += 0.2126 * a[i] + 0.7152 * a[i + 1] + 0.0722 * a[i + 2];
|
||||
const c = (S / 2) * S * 4 + (S / 2) * 4;
|
||||
const center = [a[c], a[c + 1], a[c + 2]];
|
||||
const diffAt = async (t) => {
|
||||
const v = document.createElement('video');
|
||||
v.muted = true;
|
||||
v.src = src;
|
||||
await new Promise((r, j) => ((v.onloadeddata = r), (v.onerror = j)));
|
||||
let d = v.duration;
|
||||
if (!Number.isFinite(d)) {
|
||||
v.currentTime = 1e101;
|
||||
await new Promise((r) => (v.onseeked = r));
|
||||
d = v.duration;
|
||||
}
|
||||
v.currentTime = t < 0 ? Math.max(0, d + t) : t;
|
||||
await new Promise((r) => (v.onseeked = r));
|
||||
await new Promise((r) => setTimeout(r, 120));
|
||||
const b = grab(v);
|
||||
let diff = 0;
|
||||
for (let i = 0; i < a.length; i += 4) diff += Math.abs(a[i] - b[i]) + Math.abs(a[i + 1] - b[i + 1]) + Math.abs(a[i + 2] - b[i + 2]);
|
||||
return { diff: diff / (S * S * 3), duration: d, w: v.videoWidth, h: v.videoHeight };
|
||||
};
|
||||
const tail = await diffAt(at);
|
||||
const start = await diffAt(0);
|
||||
return { mean: sum / (S * S), center, tail, start };
|
||||
},
|
||||
{ b64, src, at },
|
||||
);
|
||||
}
|
||||
|
||||
/** Verify one downloaded PNG against its source clip. */
|
||||
async function verifyDownload(page, label, download, assetPath, expect = {}) {
|
||||
const name = download.suggestedFilename();
|
||||
const dest = path.join(OUT, name);
|
||||
await download.saveAs(dest);
|
||||
const buf = fs.readFileSync(dest);
|
||||
const size = pngSize(buf);
|
||||
const base = path.basename(assetPath).replace(/\.[^.]+$/, '');
|
||||
const m = name.match(/_尾帧_(\d+\.\d{3})s\.png$/);
|
||||
ok(`${label}: 文件名对应原视频与尾帧时间`, name.startsWith(base + '_尾帧_') && !!m, name);
|
||||
ok(`${label}: 是 PNG`, !!size);
|
||||
const st = await inspectPng(page, buf.toString('base64'), fileUrl(assetPath), -0.05);
|
||||
ok(
|
||||
`${label}: 尺寸等于视频原生尺寸`,
|
||||
size && size.w === st.tail.w && size.h === st.tail.h,
|
||||
`${size?.w}×${size?.h} vs 视频 ${st.tail.w}×${st.tail.h}`,
|
||||
);
|
||||
const t = m ? Number(m[1]) : NaN;
|
||||
const back = st.tail.duration - t;
|
||||
if (expect.fellBack) {
|
||||
ok(`${label}: 片尾黑屏时回退到非黑帧`, back > 0.3 && back <= 1.05, `t=${t}s, 片长 ${st.tail.duration.toFixed(3)}s`);
|
||||
} else {
|
||||
ok(`${label}: 取的是片尾(距结尾 ≤0.06s)`, back >= 0 && back <= 0.06, `t=${t}s, 片长 ${st.tail.duration.toFixed(3)}s`);
|
||||
ok(`${label}: 与独立播放器片尾画面一致`, st.tail.diff < 6, `平均差 ${st.tail.diff.toFixed(2)},与首帧差 ${st.start.diff.toFixed(2)}`);
|
||||
}
|
||||
ok(`${label}: 非黑帧/空白帧`, st.mean > 20, `平均亮度 ${st.mean.toFixed(1)}`);
|
||||
if (expect.center) {
|
||||
const [r, g, b] = st.center;
|
||||
ok(`${label}: 画面为片尾标记色`, expect.center([r, g, b]), `中心像素 rgb(${r},${g},${b})`);
|
||||
}
|
||||
return { name, dest, size };
|
||||
}
|
||||
|
||||
/** Lightweight side servers: no-CORS, CORS, and a never-answering one. */
|
||||
function sideServers() {
|
||||
const code = `
|
||||
import http.server, socketserver, sys, threading, time, os
|
||||
os.chdir(sys.argv[1])
|
||||
class NoCors(http.server.SimpleHTTPRequestHandler):
|
||||
def log_message(self, *a): pass
|
||||
class Cors(NoCors):
|
||||
def end_headers(self):
|
||||
self.send_header('Access-Control-Allow-Origin', '*')
|
||||
super().end_headers()
|
||||
class Hang(http.server.BaseHTTPRequestHandler):
|
||||
def do_GET(self): time.sleep(60)
|
||||
def log_message(self, *a): pass
|
||||
for port, h in ((18190, NoCors), (18192, Cors), (18191, Hang)):
|
||||
s = socketserver.ThreadingTCPServer(('127.0.0.1', port), h)
|
||||
s.daemon_threads = True
|
||||
threading.Thread(target=s.serve_forever, daemon=True).start()
|
||||
print('up', flush=True)
|
||||
time.sleep(3600)
|
||||
`;
|
||||
const proc = spawn('python3', ['-c', code, SAMPLES], { stdio: ['ignore', 'pipe', 'inherit'] });
|
||||
return new Promise((resolve) => proc.stdout.once('data', () => resolve(proc)));
|
||||
}
|
||||
|
||||
const isMagenta = ([r, g, b]) => r > 150 && g < 90 && b > 90;
|
||||
const lastToast = (page) => page.locator('.toast-host .toast .msg').last();
|
||||
|
||||
const run = async () => {
|
||||
const settings = await api('/api/settings');
|
||||
const ASSETS = settings.assets_dir;
|
||||
const browser = await chromium.launch();
|
||||
const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 }, acceptDownloads: true });
|
||||
const page = await ctx.newPage();
|
||||
page.on('pageerror', (e) => console.log('PAGEERROR:', e.message));
|
||||
await page.goto(`${WEB}/video`);
|
||||
await page.waitForSelector('#desk-prompt', { timeout: 20000 });
|
||||
|
||||
// ---------- 样本:真实生成视频 + 合成横/竖/方/黑尾 ----------
|
||||
const clips = [];
|
||||
if (REAL_DIR) {
|
||||
for (const f of fs.readdirSync(REAL_DIR).filter((x) => x.endsWith('.mp4')).sort()) {
|
||||
clips.push({ label: `真实·${f}`, file: path.join(REAL_DIR, f), prompt: `尾帧验证 ${f}`, real: true });
|
||||
}
|
||||
}
|
||||
const specs = [
|
||||
{ key: 'portrait', w: 720, h: 1280, mime: 'video/mp4;codecs=avc1', mode: 'marker', ext: 'mp4' },
|
||||
{ key: 'square', w: 768, h: 768, mime: 'video/mp4;codecs=avc1', mode: 'marker', ext: 'mp4' },
|
||||
{ key: 'landscape-webm', w: 1280, h: 720, mime: 'video/webm;codecs=vp9', mode: 'marker', ext: 'webm' },
|
||||
{ key: 'fadeblack', w: 960, h: 540, mime: 'video/mp4;codecs=avc1', mode: 'fadeblack', ext: 'mp4' },
|
||||
{ key: 'allblack', w: 640, h: 360, mime: 'video/mp4;codecs=avc1', mode: 'allblack', ext: 'mp4' },
|
||||
];
|
||||
const synthFiles = {};
|
||||
for (const s of specs) {
|
||||
const b64 = await synth(page, { ...s, seconds: 2.4, fps: 24 });
|
||||
const f = path.join(SAMPLES, `synth-${s.key}.${s.ext}`);
|
||||
fs.writeFileSync(f, Buffer.from(b64, 'base64'));
|
||||
synthFiles[s.key] = f;
|
||||
}
|
||||
ok('合成竖屏/方形/WebM/黑尾样本', Object.values(synthFiles).every((f) => fs.statSync(f).size > 1000));
|
||||
clips.push({ label: '竖屏 720×1280', file: synthFiles.portrait, prompt: '尾帧验证 竖屏', center: isMagenta });
|
||||
clips.push({ label: '方形 768×768', file: synthFiles.square, prompt: '尾帧验证 方形', center: isMagenta });
|
||||
clips.push({ label: '黑尾 960×540', file: synthFiles.fadeblack, prompt: '尾帧验证 黑尾', fellBack: true });
|
||||
|
||||
for (const c of clips) c.asset = await generateWith(c.file, c.prompt);
|
||||
ok('样本均经平台生成流程落盘', clips.every((c) => c.asset && fs.existsSync(c.asset)), `${clips.length} 段`);
|
||||
const hashes = Object.fromEntries(clips.map((c) => [c.asset, sha(c.asset)]));
|
||||
const jobsBefore = (await api('/api/playground/jobs')).length;
|
||||
|
||||
// ---------- 生成结果页(检视区)----------
|
||||
await page.reload();
|
||||
await page.waitForSelector('.take', { timeout: 20000 });
|
||||
const exportBtn = page.locator('.inspector .actions button', { hasText: '导出尾帧' });
|
||||
for (const c of clips) {
|
||||
await page.locator('.take', { hasText: c.prompt }).first().click();
|
||||
await page.waitForSelector('.inspector .stage-media video', { timeout: 10000 });
|
||||
await page.waitForTimeout(400);
|
||||
// The user's own player must not jump while we take the frame.
|
||||
await page.evaluate(async () => {
|
||||
const v = document.querySelector('.inspector .stage-media video');
|
||||
v.pause();
|
||||
if (v.readyState < 1) await new Promise((r) => (v.onloadedmetadata = r));
|
||||
v.currentTime = 0.5;
|
||||
await new Promise((r) => (v.onseeked = r));
|
||||
});
|
||||
const [dl] = await Promise.all([page.waitForEvent('download', { timeout: 40000 }), exportBtn.click()]);
|
||||
await verifyDownload(page, `检视区·${c.label}`, dl, c.asset, c);
|
||||
const player = await page.evaluate(() => {
|
||||
const v = document.querySelector('.inspector .stage-media video');
|
||||
return { t: v.currentTime, paused: v.paused };
|
||||
});
|
||||
ok(`检视区·${c.label}: 用户播放器位置未被改动`, Math.abs(player.t - 0.5) < 0.01 && player.paused, `t=${player.t}`);
|
||||
await page.waitForTimeout(200);
|
||||
ok(`检视区·${c.label}: 成功提示`, ((await lastToast(page).textContent()) || '').startsWith('已导出尾帧'));
|
||||
}
|
||||
await page.screenshot({ path: path.join(OUT, '01-inspector.png') });
|
||||
|
||||
// 加载中:视频响应被拖慢时按钮进入忙碌态且不可重复点
|
||||
const slow = clips[0];
|
||||
await page.locator('.take', { hasText: slow.prompt }).first().click();
|
||||
await page.waitForTimeout(500);
|
||||
await page.route('**/api/file?**', async (route) => {
|
||||
await sleep(1500);
|
||||
await route.continue();
|
||||
});
|
||||
const dlSlow = page.waitForEvent('download', { timeout: 40000 });
|
||||
await exportBtn.click();
|
||||
await page.waitForTimeout(300);
|
||||
const busyBtn = page.locator('.inspector .actions button', { hasText: '正在导出尾帧' });
|
||||
ok('加载中:按钮显示「正在导出尾帧…」且禁用', (await busyBtn.count()) === 1 && (await busyBtn.isDisabled()));
|
||||
await page.screenshot({ path: path.join(OUT, '02-inspector-busy.png') });
|
||||
await dlSlow;
|
||||
await page.unroute('**/api/file?**');
|
||||
await page.waitForTimeout(200);
|
||||
ok('加载结束:按钮恢复可用', (await exportBtn.count()) === 1 && !(await exportBtn.isDisabled()));
|
||||
|
||||
ok('导出不改原视频文件', clips.every((c) => sha(c.asset) === hashes[c.asset]));
|
||||
ok('导出不新增/改动生成记录', (await api('/api/playground/jobs')).length === jobsBefore);
|
||||
|
||||
// 图片结果(生图台)不出现导出尾帧
|
||||
fs.writeFileSync(MODE_FILE, JSON.stringify({ mode: 'ok', delay_sec: 0 }));
|
||||
await api('/api/playground/generate', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ workflow_id: 1, input_values: { 1: '尾帧验证 图片', 2: 42 }, source: 'studio-image' }),
|
||||
});
|
||||
await sleep(1500);
|
||||
await page.goto(`${WEB}/image`);
|
||||
await page.locator('.take', { hasText: '尾帧验证 图片' }).first().click();
|
||||
await page.waitForSelector('.inspector .stage-media img', { timeout: 10000 });
|
||||
ok('图片结果不显示导出尾帧', (await page.locator('.inspector .actions button', { hasText: '导出尾帧' }).count()) === 0);
|
||||
|
||||
// ---------- 资料库 → 共用播放弹层 ----------
|
||||
await page.goto(`${WEB}/library`);
|
||||
await page.waitForSelector('.card .media', { timeout: 20000 });
|
||||
for (const c of clips.filter((x) => x.real).slice(0, 1).concat(clips.filter((x) => x.center).slice(0, 1))) {
|
||||
const name = path.basename(c.asset);
|
||||
await page.locator(`.card .media[title="${name}"]`).first().click();
|
||||
await page.waitForSelector('.backdrop .player-frame video', { timeout: 10000 });
|
||||
const tool = page.locator('.backdrop .toolbar button[aria-label="导出尾帧"]');
|
||||
ok(`弹层·${c.label}: 工具栏有导出尾帧按钮`, (await tool.count()) === 1);
|
||||
const [dl] = await Promise.all([page.waitForEvent('download', { timeout: 40000 }), tool.click()]);
|
||||
await verifyDownload(page, `弹层·${c.label}`, dl, c.asset, c);
|
||||
ok(`弹层·${c.label}: 点击后弹层不关闭`, await page.locator('.backdrop').isVisible());
|
||||
await page.waitForTimeout(250);
|
||||
const toastOnTop = await page.evaluate(() => {
|
||||
const el = document.querySelector('.toast-host .toast:last-child');
|
||||
if (!el) return false;
|
||||
const r = el.getBoundingClientRect();
|
||||
return el.contains(document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2));
|
||||
});
|
||||
ok(`弹层·${c.label}: 提示浮在弹层之上可见`, toastOnTop);
|
||||
await page.screenshot({ path: path.join(OUT, `03-lightbox-${c.center ? 'square' : 'real'}.png`) });
|
||||
await page.keyboard.press('Escape');
|
||||
await page.waitForTimeout(200);
|
||||
}
|
||||
|
||||
// ---------- 失败场景(真实提示链路:exportLastFrame → Toast)----------
|
||||
fs.mkdirSync(path.join(ASSETS, 'e2e-lastframe'), { recursive: true });
|
||||
const junk = path.join(ASSETS, 'e2e-lastframe', 'corrupt.mp4');
|
||||
fs.writeFileSync(junk, crypto.randomBytes(200000));
|
||||
const realSrc = clips.find((c) => c.real)?.asset ?? clips[0].asset;
|
||||
const truncated = path.join(ASSETS, 'e2e-lastframe', 'truncated.mp4');
|
||||
const whole = fs.readFileSync(realSrc);
|
||||
fs.writeFileSync(truncated, whole.subarray(0, Math.floor(whole.length * 0.35)));
|
||||
const allBlack = path.join(ASSETS, 'e2e-lastframe', 'allblack.mp4');
|
||||
fs.copyFileSync(synthFiles.allblack, allBlack);
|
||||
const webm = path.join(ASSETS, 'e2e-lastframe', 'recorded.webm');
|
||||
fs.copyFileSync(synthFiles['landscape-webm'], webm);
|
||||
const servers = await sideServers();
|
||||
|
||||
await page.goto(`${WEB}/video`);
|
||||
await page.waitForSelector('#desk-prompt', { timeout: 20000 });
|
||||
const tryExport = async (src) => {
|
||||
const dl = page.waitForEvent('download', { timeout: 2000 }).catch(() => null);
|
||||
const res = await page.evaluate(async (s) => (await import('/src/lib/media/lastFrame.ts')).exportLastFrame(s), src);
|
||||
await page.waitForTimeout(150);
|
||||
return { res, msg: (await lastToast(page).textContent())?.trim(), dl: await dl };
|
||||
};
|
||||
const failures_ = [
|
||||
['文件不存在', fileUrl(path.join(ASSETS, 'e2e-lastframe', 'missing.mp4')), '视频文件不存在或已被移除,无法导出尾帧'],
|
||||
['无权限(越界路径 403)', fileUrl('/etc/hostname'), '没有访问该视频的权限,无法导出尾帧'],
|
||||
['文件损坏(随机字节)', fileUrl(junk), '当前浏览器不支持该视频格式,或文件已损坏,无法导出尾帧'],
|
||||
['跨域且无 CORS', 'http://127.0.0.1:18190/synth-square.mp4', '该视频来自其他站点,浏览器禁止读取画面(跨域限制),请先下载原视频'],
|
||||
['整段片尾黑屏', fileUrl(allBlack), '视频结尾 1 秒内都是黑屏,未导出尾帧'],
|
||||
];
|
||||
for (const [label, src, want] of failures_) {
|
||||
const r = await tryExport(src);
|
||||
ok(`失败·${label}: 中文提示且不下载`, r.res === false && r.msg === want && !r.dl, r.msg);
|
||||
}
|
||||
const tr = await tryExport(fileUrl(truncated));
|
||||
ok('失败·截断的真实视频: 给出中文失败提示或仍导出有效帧', tr.res === false ? /无法|损坏|不支持/.test(tr.msg || '') : !!tr.dl, tr.msg);
|
||||
await page.screenshot({ path: path.join(OUT, '04-error-toast.png') });
|
||||
|
||||
const timeout = await page.evaluate(async () => {
|
||||
const m = await import('/src/lib/media/exportFrame.ts');
|
||||
const t0 = performance.now();
|
||||
try {
|
||||
await m.captureLastFrame('http://127.0.0.1:18191/hang.mp4', { fileTag: '尾帧', timeoutMs: 2500 });
|
||||
return { code: 'none' };
|
||||
} catch (e) {
|
||||
return { code: e.code, ms: performance.now() - t0 };
|
||||
}
|
||||
});
|
||||
ok('失败·加载超时: 按时放弃并报 timeout', timeout.code === 'timeout' && timeout.ms < 6000, JSON.stringify(timeout));
|
||||
|
||||
const UNSEEKABLE = '无法定位到视频结尾(时长未知或来源不支持拖动进度),未导出尾帧';
|
||||
const noRange = await tryExport('http://127.0.0.1:18192/synth-square.mp4');
|
||||
ok('失败·来源不支持拖动且时长未知: 中文提示,不导出首帧冒充', noRange.res === false && noRange.msg === UNSEEKABLE && !noRange.dl, noRange.msg);
|
||||
fs.copyFileSync(realSrc, path.join(SAMPLES, path.basename(realSrc)));
|
||||
const cors = await tryExport(`http://127.0.0.1:18192/${encodeURIComponent(path.basename(realSrc))}`);
|
||||
if (cors.res) {
|
||||
ok('跨域(允许 CORS)的真实视频可导出', !!cors.dl, cors.msg);
|
||||
await verifyDownload(page, '跨域 CORS·真实', cors.dl, realSrc);
|
||||
} else {
|
||||
ok('跨域(允许 CORS、无 Range)的真实视频:明确提示无法定位结尾', cors.msg === UNSEEKABLE, cors.msg);
|
||||
}
|
||||
const wb = await tryExport(fileUrl(webm));
|
||||
ok('MediaRecorder WebM(时长未知)可导出', wb.res === true && !!wb.dl, wb.msg);
|
||||
if (wb.dl) await verifyDownload(page, 'WebM 1280×720', wb.dl, webm, { center: isMagenta });
|
||||
servers.kill();
|
||||
|
||||
// ---------- 手机 ----------
|
||||
const phone = await browser.newContext({
|
||||
viewport: { width: 390, height: 844 },
|
||||
deviceScaleFactor: 3,
|
||||
isMobile: true,
|
||||
hasTouch: true,
|
||||
acceptDownloads: true,
|
||||
});
|
||||
const mp = await phone.newPage();
|
||||
await mp.goto(`${WEB}/video`);
|
||||
await mp.waitForSelector('.take', { timeout: 20000 });
|
||||
const pc = clips.find((c) => c.label.startsWith('竖屏'));
|
||||
await mp.locator('.take', { hasText: pc.prompt }).first().tap();
|
||||
await mp.waitForTimeout(600);
|
||||
const mBtn = mp.locator('.inspector .actions button', { hasText: '导出尾帧' });
|
||||
const box = await mBtn.boundingBox();
|
||||
ok('手机:检视区导出尾帧按钮在屏内可点', !!box && box.x >= 0 && box.x + box.width <= 390 && box.height >= 28, JSON.stringify(box));
|
||||
await mp.screenshot({ path: path.join(OUT, '05-phone-inspector.png') });
|
||||
const [mdl] = await Promise.all([mp.waitForEvent('download', { timeout: 40000 }), mBtn.tap()]);
|
||||
await verifyDownload(mp, '手机·竖屏', mdl, pc.asset, pc);
|
||||
await mp.goto(`${WEB}/library`);
|
||||
await mp.waitForSelector('.card .media', { timeout: 20000 });
|
||||
await mp.locator(`.card .media[title="${path.basename(pc.asset)}"]`).first().tap();
|
||||
await mp.waitForSelector('.backdrop .player-frame video', { timeout: 10000 });
|
||||
const mTool = mp.locator('.backdrop .toolbar button[aria-label="导出尾帧"]');
|
||||
const tbox = await mTool.boundingBox();
|
||||
ok('手机:弹层导出尾帧按钮在屏内', !!tbox && tbox.x >= 0 && tbox.x + tbox.width <= 390, JSON.stringify(tbox));
|
||||
const [mdl2] = await Promise.all([mp.waitForEvent('download', { timeout: 40000 }), mTool.tap()]);
|
||||
await verifyDownload(mp, '手机·弹层', mdl2, pc.asset, pc);
|
||||
await mp.waitForTimeout(250);
|
||||
await mp.screenshot({ path: path.join(OUT, '06-phone-lightbox.png') });
|
||||
|
||||
await browser.close();
|
||||
console.log(failures ? `\n${failures} check(s) FAILED` : '\nALL PASS');
|
||||
process.exit(failures ? 1 : 0);
|
||||
};
|
||||
|
||||
run().catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,315 @@
|
||||
{
|
||||
"id": "e3f2b845-8f2c-4b5a-9caf-eac1029d3e7e",
|
||||
"revision": 0,
|
||||
"last_node_id": 173,
|
||||
"last_link_id": 338,
|
||||
"nodes": [
|
||||
{
|
||||
"id": 169,
|
||||
"type": "MiniMaxH3GuidedWriter",
|
||||
"pos": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"size": [
|
||||
400,
|
||||
654
|
||||
],
|
||||
"flags": {},
|
||||
"order": 0,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "options",
|
||||
"shape": 7,
|
||||
"type": "H3_REWRITER_OPTIONS",
|
||||
"link": null
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "rewritten_prompt",
|
||||
"type": "STRING",
|
||||
"links": [
|
||||
336
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "integrated_multimodal_description",
|
||||
"type": "STRING",
|
||||
"links": null
|
||||
},
|
||||
{
|
||||
"name": "overall_soundscape",
|
||||
"type": "STRING",
|
||||
"links": null
|
||||
},
|
||||
{
|
||||
"name": "non_diegetic_music",
|
||||
"type": "STRING",
|
||||
"links": null
|
||||
}
|
||||
],
|
||||
"title": "Write the prompt",
|
||||
"properties": {
|
||||
"Node name for S&R": "MiniMaxH3GuidedWriter",
|
||||
"max_duration": 30,
|
||||
"cnr_id": "minimax-h3-prompt-rewriter",
|
||||
"ver": "a59888df88a69385d429b6865ea441e7844f49c9"
|
||||
},
|
||||
"widgets_values": [
|
||||
"图1的男人和图2的女人赤身躺在床上,女人跨坐在他身上,缓慢地起伏,双手撑在他胸口,头向后仰,呼吸越来越急。男人仰面躺着,喘息着低声说:\"看着我。\"女人俯下身吻他,镜头从侧面缓慢推近。\n",
|
||||
"on disk: Qwen3.5-9B-Uncensored-HauhauCS-Aggressive-Q4_K_M.gguf [qwen35, 5.2 GB]",
|
||||
"T2VA",
|
||||
"16:9",
|
||||
10,
|
||||
true,
|
||||
42,
|
||||
"fixed",
|
||||
false,
|
||||
"",
|
||||
"",
|
||||
false,
|
||||
"",
|
||||
false,
|
||||
""
|
||||
],
|
||||
"widgets_values_named": {
|
||||
"prompt": "图1的男人和图2的女人赤身躺在床上,女人跨坐在他身上,缓慢地起伏,双手撑在他胸口,头向后仰,呼吸越来越急。男人仰面躺着,喘息着低声说:\"看着我。\"女人俯下身吻他,镜头从侧面缓慢推近。\n",
|
||||
"model": "on disk: Qwen3.5-9B-Uncensored-HauhauCS-Aggressive-Q4_K_M.gguf [qwen35, 5.2 GB]",
|
||||
"task": "T2VA",
|
||||
"resolution": "16:9",
|
||||
"duration": 10,
|
||||
"greedy": true,
|
||||
"seed": 42,
|
||||
"control_after_generate": "fixed",
|
||||
"keep_model_loaded": false,
|
||||
"aspect_ratio": "",
|
||||
"reference_material": "",
|
||||
"bypass": false,
|
||||
"system_prompt": "",
|
||||
"repeat_last": false,
|
||||
"library_pick": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 170,
|
||||
"type": "MiniMaxH3PromptCheck",
|
||||
"pos": [
|
||||
460,
|
||||
0
|
||||
],
|
||||
"size": [
|
||||
390,
|
||||
420
|
||||
],
|
||||
"flags": {},
|
||||
"order": 1,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "options",
|
||||
"shape": 7,
|
||||
"type": "H3_REWRITER_OPTIONS",
|
||||
"link": null
|
||||
},
|
||||
{
|
||||
"label": "ref_0",
|
||||
"name": "references.ref_0",
|
||||
"shape": 7,
|
||||
"type": "IMAGE,VIDEO,AUDIO",
|
||||
"link": null
|
||||
},
|
||||
{
|
||||
"name": "prompt",
|
||||
"type": "STRING",
|
||||
"widget": {
|
||||
"name": "prompt"
|
||||
},
|
||||
"link": 336
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "prompt",
|
||||
"type": "STRING",
|
||||
"links": [
|
||||
337
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "integrated_multimodal_description",
|
||||
"type": "STRING",
|
||||
"links": null
|
||||
},
|
||||
{
|
||||
"name": "subject_definitions",
|
||||
"type": "STRING",
|
||||
"links": null
|
||||
},
|
||||
{
|
||||
"name": "summary",
|
||||
"type": "STRING",
|
||||
"links": null
|
||||
},
|
||||
{
|
||||
"name": "retention_analysis",
|
||||
"type": "STRING",
|
||||
"links": null
|
||||
},
|
||||
{
|
||||
"name": "detailed_description",
|
||||
"type": "STRING",
|
||||
"links": null
|
||||
},
|
||||
{
|
||||
"name": "overall_soundscape",
|
||||
"type": "STRING",
|
||||
"links": null
|
||||
},
|
||||
{
|
||||
"name": "non_diegetic_music",
|
||||
"type": "STRING",
|
||||
"links": null
|
||||
},
|
||||
{
|
||||
"name": "findings",
|
||||
"type": "STRING",
|
||||
"links": [
|
||||
338
|
||||
]
|
||||
}
|
||||
],
|
||||
"title": "Check it against the H3 rules",
|
||||
"properties": {
|
||||
"Node name for S&R": "MiniMaxH3PromptCheck",
|
||||
"max_duration": 30,
|
||||
"cnr_id": "minimax-h3-prompt-rewriter",
|
||||
"ver": "a59888df88a69385d429b6865ea441e7844f49c9"
|
||||
},
|
||||
"widgets_values": [
|
||||
"",
|
||||
"T2VA",
|
||||
5
|
||||
],
|
||||
"widgets_values_named": {
|
||||
"prompt": "",
|
||||
"task": "T2VA",
|
||||
"duration": 5
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 171,
|
||||
"type": "PreviewAny",
|
||||
"pos": [
|
||||
900,
|
||||
0
|
||||
],
|
||||
"size": [
|
||||
560,
|
||||
480
|
||||
],
|
||||
"flags": {},
|
||||
"order": 2,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "source",
|
||||
"type": "*",
|
||||
"link": 337
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "STRING",
|
||||
"type": "STRING",
|
||||
"links": null
|
||||
}
|
||||
],
|
||||
"title": "The finished prompt",
|
||||
"properties": {
|
||||
"Node name for S&R": "PreviewAny",
|
||||
"cnr_id": "comfy-core",
|
||||
"ver": "0.30.0"
|
||||
},
|
||||
"widgets_values": [],
|
||||
"widgets_values_named": {}
|
||||
},
|
||||
{
|
||||
"id": 172,
|
||||
"type": "PreviewAny",
|
||||
"pos": [
|
||||
900,
|
||||
520
|
||||
],
|
||||
"size": [
|
||||
560,
|
||||
240
|
||||
],
|
||||
"flags": {},
|
||||
"order": 3,
|
||||
"mode": 0,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "source",
|
||||
"type": "*",
|
||||
"link": 338
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "STRING",
|
||||
"type": "STRING",
|
||||
"links": null
|
||||
}
|
||||
],
|
||||
"title": "What the check found",
|
||||
"properties": {
|
||||
"Node name for S&R": "PreviewAny",
|
||||
"cnr_id": "comfy-core",
|
||||
"ver": "0.30.0"
|
||||
},
|
||||
"widgets_values": [],
|
||||
"widgets_values_named": {}
|
||||
}
|
||||
],
|
||||
"links": [
|
||||
[
|
||||
336,
|
||||
169,
|
||||
0,
|
||||
170,
|
||||
2,
|
||||
"STRING"
|
||||
],
|
||||
[
|
||||
337,
|
||||
170,
|
||||
0,
|
||||
171,
|
||||
0,
|
||||
"STRING"
|
||||
],
|
||||
[
|
||||
338,
|
||||
170,
|
||||
8,
|
||||
172,
|
||||
0,
|
||||
"STRING"
|
||||
]
|
||||
],
|
||||
"groups": [],
|
||||
"config": {},
|
||||
"extra": {
|
||||
"ds": {
|
||||
"scale": 1.1772972972972988,
|
||||
"offset": [
|
||||
429.8282570474093,
|
||||
283.1220192192576
|
||||
]
|
||||
},
|
||||
"frontendVersion": "1.53.10"
|
||||
},
|
||||
"version": 0.4
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
{"id":"fae76a0b-6efc-499c-ae87-9d887bcd785f","revision":0,"last_node_id":10,"last_link_id":5,"nodes":[{"id":10,"type":"DJZ-LoadLatent","pos":[960,680],"size":[390,60],"flags":{},"order":1,"mode":0,"inputs":[{"label":"latent_file","localized_name":"latent_file","name":"latent_file","type":"COMBO","widget":{"name":"latent_file"},"link":null}],"outputs":[{"label":"LATENT","localized_name":"Latent","name":"LATENT","type":"LATENT","links":[5]}],"properties":{"cnr_id":"djz-nodes","ver":"f6ca9376132600e6245d3d9d2f1e5d0ffa448d99","Node name for S&R":"DJZ-LoadLatent","aux_id":"MushroomFleet/DJZ-Nodes","ue_properties":{"widget_ue_connectable":{},"input_ue_unconnectable":{},"version":"7.4.1"}},"widgets_values":["latents\\ComfyUI_00001_nmxvu_1762517653.latent"]},{"id":3,"type":"VAEDecode","pos":[1460,760],"size":[140,50],"flags":{},"order":2,"mode":0,"inputs":[{"label":"Latent","localized_name":"Latent","name":"samples","type":"LATENT","link":5},{"label":"VAE","localized_name":"vae","name":"vae","type":"VAE","link":4}],"outputs":[{"label":"图像","localized_name":"图像","name":"IMAGE","type":"IMAGE","links":[2]}],"properties":{"cnr_id":"comfy-core","ver":"0.3.57","Node name for S&R":"VAEDecode","ue_properties":{"widget_ue_connectable":{},"version":"7.1","input_ue_unconnectable":{}}},"widgets_values":[]},{"id":4,"type":"VHS_VideoCombine","pos":[1680,750],"size":[400,334],"flags":{},"order":3,"mode":0,"inputs":[{"label":"图像","localized_name":"图像","name":"images","type":"IMAGE","link":2},{"label":"音频","localized_name":"音频","name":"audio","shape":7,"type":"AUDIO","link":null},{"label":"批次管理","localized_name":"批次管理","name":"meta_batch","shape":7,"type":"VHS_BatchManager","link":null},{"localized_name":"vae","name":"vae","shape":7,"type":"VAE","link":null},{"label":"帧率","localized_name":"帧率","name":"frame_rate","type":"FLOAT","widget":{"name":"frame_rate"},"link":null},{"label":"循环次数","localized_name":"循环次数","name":"loop_count","type":"INT","widget":{"name":"loop_count"},"link":null},{"label":"文件名前缀","localized_name":"文件名前缀","name":"filename_prefix","type":"STRING","widget":{"name":"filename_prefix"},"link":null},{"label":"格式","localized_name":"格式","name":"format","type":"COMBO","widget":{"name":"format"},"link":null},{"label":"Ping-Pong","localized_name":"Ping-Pong","name":"pingpong","type":"BOOLEAN","widget":{"name":"pingpong"},"link":null},{"label":"保存到输出文件夹","localized_name":"保存到输出文件夹","name":"save_output","type":"BOOLEAN","widget":{"name":"save_output"},"link":null},{"name":"pix_fmt","type":["yuv420p","yuv420p10le"],"widget":{"name":"pix_fmt"},"link":null},{"name":"crf","type":"INT","widget":{"name":"crf"},"link":null},{"label":"保存元数据","localized_name":"保存元数据","name":"save_metadata","type":"BOOLEAN","widget":{"name":"save_metadata"},"link":null},{"label":"修剪音频","localized_name":"修剪音频","name":"trim_to_audio","type":"BOOLEAN","widget":{"name":"trim_to_audio"},"link":null}],"outputs":[{"label":"文件名","localized_name":"文件名","name":"Filenames","type":"VHS_FILENAMES","links":null}],"properties":{"cnr_id":"comfyui-videohelpersuite","ver":"8e4d79471bf1952154768e8435a9300077b534fa","Node name for S&R":"VHS_VideoCombine","ue_properties":{"widget_ue_connectable":{},"version":"7.1","input_ue_unconnectable":{}}},"widgets_values":{"frame_rate":16,"loop_count":0,"filename_prefix":"video/WanVideo_","format":"video/h264-mp4","pix_fmt":"yuv420p","crf":19,"save_metadata":true,"trim_to_audio":false,"pingpong":false,"save_output":true,"videopreview":{"hidden":false,"paused":false,"params":{"filename":"WanVideo__00001.mp4","subfolder":"video","type":"output","format":"video/h264-mp4","frame_rate":16,"workflow":"WanVideo__00001.png","fullpath":"E:\\ComfyUI-Data\\output\\video\\WanVideo__00001.mp4"}}}},{"id":5,"type":"VAELoader","pos":[980,820],"size":[360,60],"flags":{},"order":0,"mode":0,"inputs":[{"localized_name":"vae名称","name":"vae_name","type":"COMBO","widget":{"name":"vae_name"},"link":null}],"outputs":[{"localized_name":"VAE","name":"VAE","type":"VAE","links":[4]}],"properties":{"cnr_id":"comfy-core","ver":"0.3.68","Node name for S&R":"VAELoader","ue_properties":{"widget_ue_connectable":{},"input_ue_unconnectable":{},"version":"7.4.1"}},"widgets_values":["Wan2_1_VAE_bf16.safetensors"]}],"links":[[2,3,0,4,0,"IMAGE"],[4,5,0,3,1,"VAE"],[5,10,0,3,0,"LATENT"]],"groups":[],"config":{},"extra":{"ue_links":[],"ds":{"scale":1.0834705943389082,"offset":[-573.5954979317662,-431.50654580611246]},"links_added_by_ue":[]},"version":0.4}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
{"id":"51bbecaf-42f9-4de3-95e4-b6db447eb5db","revision":0,"last_node_id":3,"last_link_id":2,"nodes":[{"id":3,"type":"PreviewImage","pos":[1480,500],"size":[400,260],"flags":{},"order":2,"mode":0,"inputs":[{"localized_name":"图像","name":"images","type":"IMAGE","link":2}],"outputs":[{"localized_name":"images","name":"images","type":"IMAGE","links":null}],"properties":{"cnr_id":"comfy-core","ver":"0.21.1","Node name for S&R":"PreviewImage","ue_properties":{"widget_ue_connectable":{},"input_ue_unconnectable":{},"version":"7.8"}},"widgets_values":[]},{"id":2,"type":"GuHaiAutoImageSplit","pos":[1160,500],"size":[270,210],"flags":{},"order":1,"mode":0,"inputs":[{"localized_name":"图像","name":"图像","type":"IMAGE","link":1},{"localized_name":"保存目录","name":"保存目录","type":"STRING","widget":{"name":"保存目录"},"link":null},{"localized_name":"水平张数","name":"水平张数","type":"INT","widget":{"name":"水平张数"},"link":null},{"localized_name":"垂直张数","name":"垂直张数","type":"INT","widget":{"name":"垂直张数"},"link":null},{"localized_name":"移除画布边缘","name":"移除画布边缘","type":"BOOLEAN","widget":{"name":"移除画布边缘"},"link":null},{"localized_name":"移除描边","name":"移除描边","type":"INT","widget":{"name":"移除描边"},"link":null},{"localized_name":"文件名前缀","name":"文件名前缀","type":"STRING","widget":{"name":"文件名前缀"},"link":null},{"localized_name":"保存格式","name":"保存格式","type":"COMBO","widget":{"name":"保存格式"},"link":null}],"outputs":[{"localized_name":"分割图像","name":"分割图像","type":"IMAGE","links":[2]}],"properties":{"aux_id":"goohai/Goohaitools-comfyui","ver":"885cac3dd323d26a77b69ae904a9a344f0dee7d0","Node name for S&R":"GuHaiAutoImageSplit","ue_properties":{"widget_ue_connectable":{},"input_ue_unconnectable":{},"version":"7.8"}},"widgets_values":["output",3,3,true,8,"孤海图像分割_","PNG"]},{"id":1,"type":"LoadImage","pos":[850,490],"size":[270,320],"flags":{},"order":0,"mode":0,"inputs":[{"localized_name":"图像","name":"image","type":"COMBO","widget":{"name":"image"},"link":null},{"localized_name":"选择文件上传","name":"upload","type":"IMAGEUPLOAD","widget":{"name":"upload"},"link":null}],"outputs":[{"localized_name":"图像","name":"IMAGE","type":"IMAGE","links":[1]},{"localized_name":"遮罩","name":"MASK","type":"MASK","links":null}],"properties":{"cnr_id":"comfy-core","ver":"0.21.1","Node name for S&R":"LoadImage","ue_properties":{"widget_ue_connectable":{},"input_ue_unconnectable":{},"version":"7.8"}},"widgets_values":["Image (4) (1).png","image"]}],"links":[[1,1,0,2,0,"IMAGE"],[2,2,0,3,0,"IMAGE"]],"groups":[{"id":1,"title":"图像分割","bounding":[810,420,1100,400],"color":"#3f789e","flags":{}}],"config":{},"extra":{"ds":{"scale":0.9090909090909091,"offset":[-259.9355305037313,15.820561879510858]},"ue_links":[]},"version":0.4}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
{"id":"74ef48f7-4441-45af-a6a0-a2bba28aeff5","revision":0,"last_node_id":18,"last_link_id":19,"nodes":[{"id":18,"type":"AudioCrop","pos":[-322,508],"size":[315,82],"flags":{},"order":1,"mode":0,"inputs":[{"label":"audio","localized_name":"audio","name":"audio","type":"AUDIO","link":18},{"label":"start_time","localized_name":"start_time","name":"start_time","type":"STRING","widget":{"name":"start_time"},"link":null},{"label":"end_time","localized_name":"end_time","name":"end_time","type":"STRING","widget":{"name":"end_time"},"link":null}],"outputs":[{"label":"AUDIO","localized_name":"音频","name":"AUDIO","type":"AUDIO","slot_index":0,"links":[19]}],"properties":{"cnr_id":"audio-separation-nodes-comfyui","ver":"1.4.0","Node name for S&R":"AudioCrop","ue_properties":{"widget_ue_connectable":{},"version":"7.4.1","input_ue_unconnectable":{}}},"widgets_values":["0:00","1:00"]},{"id":10,"type":"LoadAudio","pos":[-765,507],"size":[381.5714111328125,144],"flags":{},"order":0,"mode":0,"inputs":[{"localized_name":"音频","name":"audio","type":"COMBO","widget":{"name":"audio"},"link":null},{"localized_name":"音频UI","name":"audioUI","type":"AUDIO_UI","widget":{"name":"audioUI"},"link":null},{"localized_name":"选择文件上传","name":"upload","type":"AUDIOUPLOAD","widget":{"name":"upload"},"link":null}],"outputs":[{"label":"音频","localized_name":"音频","name":"AUDIO","type":"AUDIO","slot_index":0,"links":[18]}],"properties":{"cnr_id":"comfy-core","ver":"0.3.68","Node name for S&R":"LoadAudio","ue_properties":{"widget_ue_connectable":{},"version":"7.4.1","input_ue_unconnectable":{}}},"widgets_values":["没出息.WAV",null,null]},{"id":15,"type":"PreviewAudio","pos":[416,514],"size":[318.9408688964845,88],"flags":{},"order":3,"mode":0,"inputs":[{"label":"音频","localized_name":"音频","name":"audio","type":"AUDIO","link":15},{"localized_name":"音频UI","name":"audioUI","type":"AUDIO_UI","widget":{"name":"audioUI"},"link":null}],"outputs":[],"properties":{"cnr_id":"comfy-core","ver":"0.3.68","Node name for S&R":"PreviewAudio","ue_properties":{"widget_ue_connectable":{},"version":"7.4.1","input_ue_unconnectable":{}}},"widgets_values":[]},{"id":11,"type":"AudioSeparation","pos":[45,494],"size":[315,166],"flags":{},"order":2,"mode":0,"inputs":[{"label":"audio","localized_name":"audio","name":"audio","type":"AUDIO","link":19},{"label":"chunk_fade_shape","localized_name":"chunk_fade_shape","name":"chunk_fade_shape","shape":7,"type":"COMBO","widget":{"name":"chunk_fade_shape"},"link":null},{"label":"chunk_length","localized_name":"chunk_length","name":"chunk_length","shape":7,"type":"FLOAT","widget":{"name":"chunk_length"},"link":null},{"label":"chunk_overlap","localized_name":"chunk_overlap","name":"chunk_overlap","shape":7,"type":"FLOAT","widget":{"name":"chunk_overlap"},"link":null}],"outputs":[{"label":"Bass","localized_name":"Bass","name":"Bass","type":"AUDIO","links":null},{"label":"Drums","localized_name":"Drums","name":"Drums","type":"AUDIO","links":null},{"label":"Other","localized_name":"Other","name":"Other","type":"AUDIO","links":null},{"label":"Vocals","localized_name":"Vocals","name":"Vocals","type":"AUDIO","slot_index":3,"links":[15]}],"properties":{"cnr_id":"audio-separation-nodes-comfyui","ver":"1.4.0","Node name for S&R":"AudioSeparation","ue_properties":{"widget_ue_connectable":{},"version":"7.4.1","input_ue_unconnectable":{}}},"widgets_values":["logarithmic",16,1.1]}],"links":[[15,11,3,15,0,"AUDIO"],[18,10,0,18,0,"AUDIO"],[19,18,0,11,0,"AUDIO"]],"groups":[],"config":{},"extra":{"ue_links":[],"links_added_by_ue":[],"ds":{"scale":0.9158251011505646,"offset":[1084.0109668805326,-51.53135329805568]}},"version":0.4}
|
||||
@@ -0,0 +1 @@
|
||||
{"id":"48bb093c-f7a8-421c-8fc4-2b6acc133512","revision":0,"last_node_id":4,"last_link_id":3,"nodes":[{"id":4,"type":"SaveAudioMP3","pos":[580,23110],"size":[270,136],"flags":{},"order":1,"mode":0,"inputs":[{"label":"音频","localized_name":"音频","name":"audio","type":"AUDIO","link":3},{"label":"文件名前缀","localized_name":"文件名前缀","name":"filename_prefix","type":"STRING","widget":{"name":"filename_prefix"},"link":null},{"label":"品质","localized_name":"品质","name":"quality","type":"COMBO","widget":{"name":"quality"},"link":null},{"localized_name":"audioUI","name":"audioUI","type":"AUDIO_UI","widget":{"name":"audioUI"},"link":null}],"outputs":[],"properties":{"ue_properties":{"widget_ue_connectable":{},"input_ue_unconnectable":{}},"Node name for S&R":"SaveAudioMP3"},"widgets_values":["audio/ComfyUI","V0"]},{"id":1,"type":"LoadAudio","pos":[180,23110],"size":[310,140],"flags":{},"order":0,"mode":0,"inputs":[{"localized_name":"音频","name":"audio","type":"COMBO","widget":{"name":"audio"},"link":null},{"localized_name":"音频UI","name":"audioUI","type":"AUDIO_UI","widget":{"name":"audioUI"},"link":null},{"localized_name":"选择文件上传","name":"upload","type":"AUDIOUPLOAD","widget":{"name":"upload"},"link":null}],"outputs":[{"localized_name":"音频","name":"AUDIO","type":"AUDIO","links":[3]}],"properties":{"ue_properties":{"widget_ue_connectable":{},"input_ue_unconnectable":{}},"Node name for S&R":"LoadAudio"},"widgets_values":["0001.G.E.M. 邓紫棋 - 光年之外.m4a",null,""]}],"links":[[3,1,0,4,0,"AUDIO"]],"groups":[],"config":{},"extra":{"ue_links":[],"links_added_by_ue":[],"ds":{"scale":1.2839025177495265,"offset":[349.7067995460809,-22788.486109072262]}},"version":0.4}
|
||||
@@ -0,0 +1 @@
|
||||
{"id":"e6b92a63-6d7e-4d2b-b9e3-2e054825db02","revision":0,"last_node_id":7,"last_link_id":6,"nodes":[{"id":3,"type":"SaveImage","pos":[-500,-530],"size":[280,280],"flags":{},"order":2,"mode":0,"inputs":[{"localized_name":"图片","name":"images","type":"IMAGE","link":2},{"localized_name":"文件名前缀","name":"filename_prefix","type":"STRING","widget":{"name":"filename_prefix"},"link":null}],"outputs":[],"properties":{"Node name for S&R":"SaveImage","cnr_id":"comfy-core","ver":"0.16.4","enableTabs":false,"tabWidth":65,"tabXOffset":10,"hasSecondTab":false,"secondTabText":"Send Back","secondTabOffset":80,"secondTabWidth":65,"ue_properties":{"widget_ue_connectable":{},"version":"7.7","input_ue_unconnectable":{}}},"widgets_values":["ComfyUI"]},{"id":1,"type":"RTXVideoSuperResolution","pos":[-830,-560],"size":[300,110],"flags":{},"order":1,"mode":0,"inputs":[{"localized_name":"images","name":"images","type":"IMAGE","link":1},{"localized_name":"resize_type","name":"resize_type","type":"COMFY_DYNAMICCOMBO_V3","widget":{"name":"resize_type"},"link":null},{"localized_name":"resize_type.scale","name":"resize_type.scale","type":"FLOAT","widget":{"name":"resize_type.scale"},"link":null},{"localized_name":"quality","name":"quality","type":"COMBO","widget":{"name":"quality"},"link":null}],"outputs":[{"localized_name":"upscaled_images","name":"upscaled_images","type":"IMAGE","links":[2,5]}],"properties":{"Node name for S&R":"RTXVideoSuperResolution","aux_id":"Comfy-Org/Nvidia_RTX_Nodes_ComfyUI","ver":"0.1.0","cnr_id":"comfyui_nvidia_rtx_nodes","enableTabs":false,"tabWidth":65,"tabXOffset":10,"hasSecondTab":false,"secondTabText":"Send Back","secondTabOffset":80,"secondTabWidth":65,"ue_properties":{"widget_ue_connectable":{},"version":"7.7","input_ue_unconnectable":{}}},"widgets_values":["scale by multiplier",2,"ULTRA"]},{"id":2,"type":"LoadImage","pos":[-1150,-630],"size":[290,320],"flags":{},"order":0,"mode":0,"inputs":[{"localized_name":"图像","name":"image","type":"COMBO","widget":{"name":"image"},"link":null},{"localized_name":"选择文件上传","name":"upload","type":"IMAGEUPLOAD","widget":{"name":"upload"},"link":null}],"outputs":[{"localized_name":"图像","name":"IMAGE","type":"IMAGE","links":[1,6]},{"localized_name":"遮罩","name":"MASK","type":"MASK","links":null}],"properties":{"Node name for S&R":"LoadImage","cnr_id":"comfy-core","ver":"0.16.4","enableTabs":false,"tabWidth":65,"tabXOffset":10,"hasSecondTab":false,"secondTabText":"Send Back","secondTabOffset":80,"secondTabWidth":65,"ue_properties":{"widget_ue_connectable":{},"version":"7.7","input_ue_unconnectable":{}}},"widgets_values":["ComfyUI_01117_.png","image"]},{"id":7,"type":"Image Comparer (rgthree)","pos":[-180,-620],"size":[210,78],"flags":{},"order":3,"mode":0,"inputs":[{"dir":3,"label":"图像_A","localized_name":"图像_A","name":"image_a","type":"IMAGE","link":6},{"dir":3,"label":"图像_B","localized_name":"图像_B","name":"image_b","type":"IMAGE","link":5}],"outputs":[],"title":"图像对比","properties":{"ue_properties":{"widget_ue_connectable":{},"input_ue_unconnectable":{}},"comparer_mode":"Slide"},"widgets_values":[[]]}],"links":[[1,2,0,1,0,"IMAGE"],[2,1,0,3,0,"IMAGE"],[5,1,0,7,1,"IMAGE"],[6,2,0,7,0,"IMAGE"]],"groups":[],"config":{},"extra":{"workflowRendererVersion":"Vue-corrected","ds":{"scale":1.7985878990921387,"offset":[589.555558343045,830.7344763619243]},"frontendVersion":"1.39.19","VHS_latentpreview":false,"VHS_latentpreviewrate":0,"VHS_MetadataImage":true,"VHS_KeepIntermediate":true,"ue_links":[],"links_added_by_ue":[]},"version":0.4}
|
||||
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user