feat: support native fifteen-second shots in video creation and workflows
@ -82,12 +82,25 @@ async def build_asset(settings, owner_id, asset_id, path, name, **fields):
|
||||
duration_seconds=metadata.get("duration_seconds"), tags=[], favorite=False, **fields)
|
||||
|
||||
|
||||
async def validate_workflow_output(job, source, settings):
|
||||
if job.run_id and job.step_key != "compose" and job.task_type == "video.generate":
|
||||
from .media import inspect_video_track
|
||||
source_frames = job.parameters.get('num_frames',121)
|
||||
if not isinstance(source_frames,int) or isinstance(source_frames,bool):
|
||||
raise ValueError("Workflow shot does not meet frozen decoded video specification")
|
||||
required = max(120,source_frames-1)
|
||||
track = await inspect_video_track(source,settings)
|
||||
if track['frames']<required or track['fps']!=24 or (track['width'],track['height'])!=(job.parameters.get('upscale_width'),job.parameters.get('upscale_height')):
|
||||
raise ValueError("Workflow shot does not meet frozen decoded video specification")
|
||||
|
||||
|
||||
async def import_output(db, settings, job, source, index, *, execution_fence=None):
|
||||
async with db.session() as session:
|
||||
current = await session.scalar(select(Job).where(Job.id == job.id, Job.owner_id == job.owner_id,
|
||||
Job.deleted_at.is_(None)))
|
||||
if current is None:
|
||||
raise ValueError("Archived job cannot import output")
|
||||
job = current
|
||||
existing = await session.scalar(select(Asset).where(Asset.source_job_id == job.id,
|
||||
Asset.source_output_index == index))
|
||||
if existing:
|
||||
@ -95,21 +108,19 @@ async def import_output(db, settings, job, source, index, *, execution_fence=Non
|
||||
from .v2_models import AssetReference
|
||||
binding=await session.scalar(select(AssetReference.id).where(AssetReference.asset_id==existing.id,AssetReference.ref_kind=="execution",AssetReference.ref_id==execution_fence["execution_id"]))
|
||||
if not binding:raise ValueError("Output belongs to a different execution")
|
||||
from .artifacts import digest_file
|
||||
path=confined(settings.asset_root,existing.storage_key,exists=True)
|
||||
with safe_file(settings.asset_root,path):pass
|
||||
if path.stat().st_size!=existing.size_bytes or digest_file(path)!=existing.sha256:
|
||||
raise ValueError("Imported artifact is missing or corrupt")
|
||||
return existing
|
||||
if existing:
|
||||
from .artifacts import digest_file
|
||||
path=confined(settings.asset_root,existing.storage_key,exists=True)
|
||||
with safe_file(settings.asset_root,path):pass
|
||||
if path.stat().st_size!=existing.size_bytes or digest_file(path)!=existing.sha256:
|
||||
raise ValueError("Imported artifact is missing or corrupt")
|
||||
await validate_workflow_output(job,path,settings)
|
||||
return existing
|
||||
asset_id = new_id()
|
||||
source = confined(settings.job_work_root, source, exists=True)
|
||||
if source.stat().st_size>settings.max_output_bytes:
|
||||
raise ValueError("Output exceeds reserved asset limit; retained for operator reconciliation")
|
||||
if job.run_id and job.step_key != "compose" and job.task_type == "video.generate":
|
||||
from .media import inspect_video_track
|
||||
track=await inspect_video_track(source,settings)
|
||||
if track["frames"]<120 or track["fps"]!=24 or (track["width"],track["height"])!=(job.parameters.get("upscale_width"),job.parameters.get("upscale_height")):
|
||||
raise ValueError("Workflow shot does not meet frozen decoded video specification")
|
||||
await validate_workflow_output(job,source,settings)
|
||||
directory = confined(settings.asset_root, Path(job.owner_id) / asset_id)
|
||||
directory.mkdir(parents=True)
|
||||
suffix = source.suffix.lower() if re.fullmatch(r"\.[a-z0-9]{1,10}", source.suffix.lower()) else ".bin"
|
||||
@ -252,17 +263,10 @@ async def patch_asset(asset_id: str, body: AssetPatch, request: Request, actor:
|
||||
@router.delete("/{asset_id}", status_code=204)
|
||||
async def delete_asset(asset_id: str, request: Request, actor: Actor = Depends(csrf_actor)):
|
||||
async with request.app.state.db.session() as session:
|
||||
asset = await owned_asset(session, asset_id, actor.id)
|
||||
from .v2_models import AssetReference, Submission
|
||||
ref = await session.scalar(select(AssetReference.id).where(AssetReference.asset_id==asset_id,AssetReference.ref_kind!="execution").limit(1))
|
||||
if ref:
|
||||
fail(409,"asset_in_use","Asset is referenced by a workflow")
|
||||
from .jobs import TERMINAL
|
||||
active_input = await session.scalar(select(JobAsset.job_id).join(Job, Job.id == JobAsset.job_id).where(
|
||||
JobAsset.asset_id == asset_id, Job.deleted_at.is_(None), Job.state.notin_(TERMINAL)).limit(1))
|
||||
if active_input:
|
||||
fail(409, "asset_in_use", "素材正在被活动任务使用")
|
||||
asset.deleted_at = utcnow()
|
||||
asset = await owned_asset(session, asset_id, actor.id, include_deleted=True)
|
||||
from .asset_deletion import remove_asset
|
||||
from .v2_models import Submission
|
||||
await remove_asset(session, request.app.state.settings, asset)
|
||||
# Match the deleted result only: a publication's private source may be
|
||||
# deleted while its independent shared snapshot remains available.
|
||||
await session.execute(update(Submission).where(
|
||||
@ -271,7 +275,6 @@ async def delete_asset(asset_id: str, request: Request, actor: Actor = Depends(c
|
||||
emit_asset(session, actor.id, "asset.deleted", {"id": asset.id})
|
||||
await touch_source_job(session, asset)
|
||||
await session.commit()
|
||||
# Physical deletion is exclusively handled by the dry-run-first retention service.
|
||||
return Response(status_code=204)
|
||||
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ from pathlib import Path
|
||||
import re
|
||||
from filelock import FileLock
|
||||
from sqlalchemy import case, or_, select
|
||||
from .assets import confined, import_output, safe_file
|
||||
from .assets import confined, import_output, safe_file, validate_workflow_output
|
||||
from .dto import asset_dto, public_value
|
||||
from .events import emit_asset, emit_job
|
||||
from .jobs import GPU_TYPES, TERMINAL
|
||||
@ -521,6 +521,7 @@ class Coordinator:
|
||||
path=confined(self.settings.asset_root,existing.storage_key,exists=True)
|
||||
if path.stat().st_size!=existing.size_bytes or digest_file(path)!=existing.sha256:
|
||||
raise ValueError("Imported artifact is missing or corrupt")
|
||||
await validate_workflow_output(job,path,self.settings)
|
||||
assets.append(existing)
|
||||
continue
|
||||
raw = output.get("path", "") if isinstance(output, dict) else str(output)
|
||||
|
||||
@ -10,6 +10,13 @@ from . import assets, auth, events, jobs, submissions, tokens, workflows, batche
|
||||
from .config import Settings
|
||||
from .coordinator import Coordinator
|
||||
from .database import Database
|
||||
from .timeline import DEFAULT_SOURCE_FRAMES, MAX_SOURCE_FRAMES, DEFAULT_CLIP_FRAMES, MAX_CLIP_FRAMES
|
||||
|
||||
|
||||
def workflow_limits(policy):
|
||||
return {"max_shots":policy["workflow_max_shots"],"source_frames":DEFAULT_SOURCE_FRAMES,
|
||||
"default_source_frames":DEFAULT_SOURCE_FRAMES,"max_source_frames":MAX_SOURCE_FRAMES,
|
||||
"default_clip_frames":DEFAULT_CLIP_FRAMES,"max_clip_frames":MAX_CLIP_FRAMES,"fps":24}
|
||||
|
||||
|
||||
def create_app(settings=None, *, provider=None):
|
||||
@ -117,7 +124,7 @@ def create_app(settings=None, *, provider=None):
|
||||
policy=read_runtime_policy(app.state.settings)
|
||||
return {"items": provider_capabilities(app.state.settings),
|
||||
"scheduler": await app.state.provider.scheduler_status(), "execution_policy": execution_policy(settings=app.state.settings),
|
||||
"workflow_limits":{"max_shots":policy["workflow_max_shots"],"source_frames":121,"max_clip_frames":120,"fps":24}}
|
||||
"workflow_limits":workflow_limits(policy)}
|
||||
|
||||
@app.get("/api/system/status", dependencies=[Depends(auth.current_actor)])
|
||||
async def status():
|
||||
@ -130,7 +137,7 @@ def create_app(settings=None, *, provider=None):
|
||||
"environment": app.state.settings.mode,
|
||||
"database_backend": app.state.settings.sqlalchemy_url.get_backend_name(),
|
||||
"execution_policy": execution_policy(settings=app.state.settings),
|
||||
"workflow_limits":{"max_shots":policy["workflow_max_shots"],"source_frames":121,"max_clip_frames":120,"fps":24},
|
||||
"workflow_limits":workflow_limits(policy),
|
||||
"public_access": getattr(app.state.settings, "public_access", False)}
|
||||
|
||||
return app
|
||||
|
||||
@ -98,7 +98,7 @@ def capabilities(settings) -> list[dict]:
|
||||
num_frames=121, fps=24, upscale=True, upscale_width=1920, upscale_height=1080, tile_size=128)
|
||||
video_limits = {**image_limits, 'width': {'min': 256, 'max': 1280, 'step': 32},
|
||||
'height': {'min': 256, 'max': 1280, 'step': 32}, 'max_pixels': 1280 * 704,
|
||||
'count': {'min': 1, 'max': 1}, 'num_frames': {'min': 5, 'max': 121, 'step': 4},
|
||||
'count': {'min': 1, 'max': 1}, 'num_frames': {'min': 5, 'max': 361, 'step': 4},
|
||||
'fps': {'values': [24]}, 'upscale': {'values': [True, False]},
|
||||
'upscale_width': {'min': 256, 'max': 3840, 'step': 2},
|
||||
'upscale_height': {'min': 256, 'max': 2160, 'step': 2}, 'tile_size': {'min': 64, 'max': 256, 'step': 16}}
|
||||
@ -112,7 +112,7 @@ def capabilities(settings) -> list[dict]:
|
||||
item('image.generate', '图像生成', 'Qwen-Image', configured, ['text'], image_defaults, image_limits,
|
||||
'文字生成图片;不包含图像编辑或风格 LoRA 管理。'),
|
||||
item('video.generate', '视频生成', 'Wan2.2-TI2V-5B + Real-ESRGAN', configured, ['text', 'image'],
|
||||
video_defaults, video_limits, '最多121帧、24fps,约5秒无声视频;可选1080p增强。'),
|
||||
video_defaults, video_limits, '单镜头最多361帧、24fps,约15秒无声视频;默认约5秒,可选1080p增强。'),
|
||||
item('defect.generate', '条件样本生成', 'SDXL + Canny ControlNet', configured, ['text', 'image'],
|
||||
dict(image_defaults, guidance_scale=7.5, controlnet_conditioning_scale=.8, canny_low=100, canny_high=200),
|
||||
{**image_limits, 'controlnet_conditioning_scale': {'min': 0, 'max': 2},
|
||||
@ -182,7 +182,7 @@ def validate_arguments(task_type: str, inputs: dict, parameters: dict, settings=
|
||||
if p['canny_low'] >= p['canny_high']:
|
||||
raise _invalid('Canny低阈值必须小于高阈值。')
|
||||
if video:
|
||||
_int(p['num_frames'], 5, 121)
|
||||
_int(p['num_frames'], 5, 361)
|
||||
if p['num_frames'] % 4 != 1 or type(p['fps']) is not int or p['fps'] != 24 or type(p['upscale']) is not bool:
|
||||
raise _invalid('视频帧数、帧率或增强开关无效。')
|
||||
_int(p['upscale_width'], 256, 3840, 2)
|
||||
@ -475,9 +475,9 @@ class Provider:
|
||||
if normalized['canny_low'] >= normalized['canny_high']:
|
||||
raise _invalid('Canny低阈值必须小于高阈值。')
|
||||
if video:
|
||||
_int(normalized['num_frames'], 5, 121)
|
||||
_int(normalized['num_frames'], 5, 361)
|
||||
if normalized['num_frames'] % 4 != 1 or type(normalized['fps']) is not int or normalized['fps'] != 24:
|
||||
raise _invalid('视频仅支持4n+1帧、最多121帧和24fps。')
|
||||
raise _invalid('视频仅支持4n+1帧、最多361帧和24fps。')
|
||||
if type(normalized['upscale']) is not bool:
|
||||
raise _invalid('增强开关必须为布尔值。')
|
||||
_int(normalized['upscale_width'], 256, 3840, 2)
|
||||
|
||||
@ -1,9 +1,16 @@
|
||||
"""Versioned short-clip story contract. Public fields contain no executable paths."""
|
||||
from dataclasses import dataclass
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Literal
|
||||
import re
|
||||
from pydantic import BaseModel, ConfigDict, Field, model_serializer, model_validator
|
||||
|
||||
DEFAULT_CLIP_FRAMES = 120
|
||||
MAX_CLIP_FRAMES = 360
|
||||
DEFAULT_SOURCE_FRAMES = 121
|
||||
MAX_SOURCE_FRAMES = 361
|
||||
MAX_WORKFLOW_SHOTS = 1000
|
||||
MAX_TIMELINE_FRAMES = MAX_WORKFLOW_SHOTS * MAX_CLIP_FRAMES
|
||||
|
||||
class Strict(BaseModel):
|
||||
model_config = ConfigDict(extra='forbid', strict=True)
|
||||
|
||||
@ -13,7 +20,7 @@ class ShotParameters(Strict):
|
||||
class Shot(Strict):
|
||||
key: str = Field(pattern=r'^shot_[1-9][0-9]{0,3}$')
|
||||
prompt: str = Field(min_length=1,max_length=8000)
|
||||
duration_frames: int = Field(default=120,ge=24,le=120)
|
||||
duration_frames: int = Field(default=DEFAULT_CLIP_FRAMES,ge=24,le=MAX_CLIP_FRAMES)
|
||||
image_asset_id: str | None = Field(default=None,min_length=1,max_length=64)
|
||||
parameters: ShotParameters = Field(default_factory=ShotParameters)
|
||||
@model_validator(mode='after')
|
||||
@ -45,7 +52,7 @@ class Audio(Strict):
|
||||
|
||||
class Render(Strict):
|
||||
fps: Literal[24] = 24
|
||||
total_frames: int | None = Field(default=None,ge=1,le=120000)
|
||||
total_frames: int | None = Field(default=None,ge=1,le=MAX_TIMELINE_FRAMES)
|
||||
fit: Literal['contain','cover'] = 'contain'
|
||||
audio: Audio | None = None
|
||||
subtitles: list[Subtitle] = Field(default_factory=list,max_length=1000)
|
||||
@ -53,7 +60,7 @@ class Render(Strict):
|
||||
|
||||
class WorkflowSpec(Strict):
|
||||
schema_version: Literal[1,2] = 1
|
||||
shots: list[Shot] = Field(min_length=1,max_length=1000)
|
||||
shots: list[Shot] = Field(min_length=1,max_length=MAX_WORKFLOW_SHOTS)
|
||||
profile: Literal['landscape_1080_v1','portrait_1080_v1'] = 'landscape_1080_v1'
|
||||
render: Render = Field(default_factory=Render)
|
||||
@model_validator(mode='after')
|
||||
@ -63,6 +70,8 @@ class WorkflowSpec(Strict):
|
||||
if [s.key for s in self.shots] != [f'shot_{i}' for i in range(1,len(self.shots)+1)]:
|
||||
raise ValueError('exact ordered sequential shot keys required')
|
||||
frames = sum(s.duration_frames for s in self.shots)
|
||||
if frames > MAX_TIMELINE_FRAMES:
|
||||
raise ValueError('invalid_timeline: total frames exceed maximum story length')
|
||||
if self.render.total_frames is not None and self.render.total_frames != frames:
|
||||
raise ValueError('invalid_timeline: total_frames differs from shots')
|
||||
self.render.total_frames = frames
|
||||
@ -89,6 +98,7 @@ class TimelinePlan:
|
||||
clip_frames: int = 120
|
||||
fps: int = 24
|
||||
shot_frames: tuple[int,...] = ()
|
||||
shot_generation_parameters: dict[str,dict] = field(default_factory=dict)
|
||||
|
||||
|
||||
def ordered_step_keys(snapshot):
|
||||
@ -96,6 +106,17 @@ def ordered_step_keys(snapshot):
|
||||
return [shot['key'] for shot in snapshot['shots']] + ['compose']
|
||||
|
||||
|
||||
def generation_parameters_for_shot(snapshot, key):
|
||||
"""Read accepted source parameters; legacy snapshots keep their original base."""
|
||||
compiled = snapshot['compiled']
|
||||
if 'shot_generation_parameters' not in compiled:
|
||||
return compiled['generation_parameters']
|
||||
parameters = compiled['shot_generation_parameters']
|
||||
if not isinstance(parameters,dict) or key not in parameters or not isinstance(parameters[key],dict) or 'num_frames' not in parameters[key]:
|
||||
raise ValueError('Frozen shot generation parameters are incomplete')
|
||||
return parameters[key]
|
||||
|
||||
|
||||
def compile_timeline(spec, owned_assets) -> TimelinePlan:
|
||||
spec = spec if isinstance(spec,WorkflowSpec) else WorkflowSpec.model_validate(spec)
|
||||
audio = spec.render.audio
|
||||
@ -106,7 +127,10 @@ def compile_timeline(spec, owned_assets) -> TimelinePlan:
|
||||
raise ValueError('invalid_timeline: audio source cut exceeds source')
|
||||
portrait = spec.profile == 'portrait_1080_v1'
|
||||
parameters = dict(width=704 if portrait else 1280,height=1280 if portrait else 704,
|
||||
num_frames=121,fps=24,upscale=True,upscale_width=1056 if portrait else 1920,
|
||||
num_frames=DEFAULT_SOURCE_FRAMES,fps=24,upscale=True,upscale_width=1056 if portrait else 1920,
|
||||
upscale_height=1920 if portrait else 1056,num_inference_steps=50,guidance_scale=5.0,tile_size=128)
|
||||
per_shot = {shot.key:{**parameters,'num_frames':max(DEFAULT_SOURCE_FRAMES,4*((shot.duration_frames+3)//4)+1)}
|
||||
for shot in spec.shots}
|
||||
return TimelinePlan(spec.model_dump(mode='json'),parameters,(1080,1920) if portrait else (1920,1080),
|
||||
frames=spec.render.total_frames,shot_frames=tuple(s.duration_frames for s in spec.shots))
|
||||
frames=spec.render.total_frames,shot_frames=tuple(s.duration_frames for s in spec.shots),
|
||||
shot_generation_parameters=per_shot)
|
||||
|
||||
@ -15,7 +15,7 @@ from .events import emit_asset, emit_job
|
||||
from .jobs import create_jobs, Submit, TERMINAL, GPU_TYPES
|
||||
from .models import Asset, Event, Job, User, utcnow
|
||||
from .submissions import accept_submission
|
||||
from .timeline import Strict, WorkflowSpec, compile_timeline, ordered_step_keys
|
||||
from .timeline import Strict, WorkflowSpec, compile_timeline, ordered_step_keys, generation_parameters_for_shot
|
||||
from .runtime_policy import read_runtime_policy
|
||||
from .v2_models import WorkflowDraft, WorkflowRun, WorkflowStep, AssetReference, Execution
|
||||
|
||||
@ -139,7 +139,9 @@ async def create_run(session,owner_id,draft_id,expected_version,revision,mode='i
|
||||
if mode=='interactive':
|
||||
active=await session.scalar(select(WorkflowRun.id).where(WorkflowRun.owner_id==owner_id,WorkflowRun.deleted_at.is_(None),WorkflowRun.execution_mode=='interactive',WorkflowRun.state.not_in(RUN_TERMINAL)))
|
||||
if active:fail(429,'quota_exceeded','已有活动交互工作流')
|
||||
snapshot={**plan.spec,'compiled':{'generation_parameters':plan.generation_parameters,'canvas':list(plan.canvas),'preset_version':'wan-three-shot-v1' if plan.spec['schema_version']==1 else 'wan-multi-shot-v2'}}
|
||||
snapshot={**plan.spec,'compiled':{'generation_parameters':plan.generation_parameters,
|
||||
'shot_generation_parameters':plan.shot_generation_parameters,'canvas':list(plan.canvas),
|
||||
'preset_version':'wan-three-shot-v1' if plan.spec['schema_version']==1 else 'wan-multi-shot-v2'}}
|
||||
r=WorkflowRun(owner_id=owner_id,draft_id=d.id,draft_revision=d.revision,spec_snapshot=snapshot,spec_hash=digest(snapshot),execution_mode=mode,batch_id=batch_id,batch_item_index=batch_item_index)
|
||||
session.add(r);await session.flush()
|
||||
reuse=None
|
||||
@ -147,7 +149,7 @@ async def create_run(session,owner_id,draft_id,expected_version,revision,mode='i
|
||||
for shot in plan.spec['shots']:
|
||||
source=assets.get(shot.get('image_asset_id'))
|
||||
generation_shot={k:v for k,v in shot.items() if k!='duration_frames'}
|
||||
h=digest({'shot':generation_shot,'generation_parameters':plan.generation_parameters,'source_sha256':source.sha256 if source else None})
|
||||
h=digest({'shot':generation_shot,'generation_parameters':plan.shot_generation_parameters[shot['key']],'source_sha256':source.sha256 if source else None})
|
||||
step=WorkflowStep(run_id=r.id,step_key=shot['key'],kind='video.generate',dependencies=[],semantic_input_hash=h)
|
||||
if reuse:
|
||||
old=await session.scalar(select(WorkflowStep).where(WorkflowStep.run_id==reuse.id,WorkflowStep.step_key==shot['key'],WorkflowStep.semantic_input_hash==h,WorkflowStep.state=='succeeded'))
|
||||
@ -176,7 +178,7 @@ async def create_child(session,r,step,settings):
|
||||
shot=next(s for s in snapshot['shots'] if s['key']==step.step_key)
|
||||
inputs={'prompt':shot['prompt']}
|
||||
if shot.get('image_asset_id'):inputs['image_asset_id']=shot['image_asset_id']
|
||||
p={**snapshot['compiled']['generation_parameters'],**shot['parameters']}
|
||||
p={**generation_parameters_for_shot(snapshot,step.step_key),**shot['parameters']}
|
||||
else:
|
||||
steps=(await session.scalars(select(WorkflowStep).where(WorkflowStep.run_id==r.id,WorkflowStep.kind=='video.generate'))).all()
|
||||
bykey={s.step_key:s for s in steps}
|
||||
|
||||
35
backend/tests/media_longshot_linux.py
Normal file
@ -0,0 +1,35 @@
|
||||
"""Explicit real-FFmpeg acceptance for mixed native-length workflow clips."""
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from app.media import MediaError, compose_workflow, inspect_video_track, run_process
|
||||
from app.timeline import compile_timeline
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_real_five_ten_fifteen_second_clips_produce_thirty_seconds(tmp_path):
|
||||
settings = SimpleNamespace(workspace_root=tmp_path, ffmpeg_bin='ffmpeg', ffprobe_bin='ffprobe',
|
||||
max_output_bytes=100 * 1024 * 1024)
|
||||
body = {'schema_version': 2, 'profile': 'landscape_1080_v1', 'shots': [
|
||||
{'key': f'shot_{i}', 'prompt': f'shot {i}', 'duration_frames': frames}
|
||||
for i, frames in enumerate((120, 240, 360), 1)]}
|
||||
plan = compile_timeline(body, {})
|
||||
sources = []
|
||||
for index, color in enumerate(('red', 'green', 'blue'), 1):
|
||||
source = tmp_path / f'source-{index}.mp4'
|
||||
frames = plan.shot_generation_parameters[f'shot_{index}']['num_frames']
|
||||
await run_process(['ffmpeg', '-v', 'error', '-f', 'lavfi', '-i',
|
||||
f'color=c={color}:s=1920x1056:r=24', '-frames:v', str(frames),
|
||||
'-c:v', 'libx264', '-preset', 'ultrafast', '-threads', '2', str(source)])
|
||||
sources.append(source)
|
||||
output = await compose_workflow(plan, tmp_path / 'output', settings=settings, sources=sources)
|
||||
track = await inspect_video_track(output.outputs[0], settings)
|
||||
assert track['frames'] == 720 and track['fps'] == 24
|
||||
assert (track['width'], track['height']) == (1920, 1080)
|
||||
assert abs(track['duration'] - 30) < .05
|
||||
await run_process(['ffmpeg', '-v', 'error', '-threads', '2', '-i', str(output.outputs[0]), '-f', 'null', '-'])
|
||||
# A real short source cannot be stretched or frozen to impersonate15 seconds.
|
||||
with pytest.raises(MediaError):
|
||||
await compose_workflow(plan, tmp_path / 'invalid-output', settings=settings,
|
||||
sources=[sources[0], sources[1], sources[0]])
|
||||
290
backend/tests/test_long_shots.py
Normal file
@ -0,0 +1,290 @@
|
||||
"""Native per-shot source lengths remain frozen across revisions and retries."""
|
||||
import copy
|
||||
import hashlib
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
from sqlalchemy import select
|
||||
|
||||
from app.models import Asset, Job, new_id
|
||||
from app.timeline import Render, WorkflowSpec, compile_timeline
|
||||
from app.v2_models import WorkflowRun, WorkflowStep
|
||||
from app.workflow_engine import advance_workflows
|
||||
from app.workflows import digest
|
||||
from test_multishot_v3 import story
|
||||
from test_timeline_v2 import spec
|
||||
from test_workflows_v2 import wf, run, publish_video
|
||||
|
||||
|
||||
def test_mixed_native_generation_lengths_are_per_shot():
|
||||
plan = compile_timeline(story(durations=[120, 240, 360]), {})
|
||||
assert plan.frames == 720 and plan.shot_frames == (120, 240, 360)
|
||||
assert plan.generation_parameters['num_frames'] == 121
|
||||
assert [plan.shot_generation_parameters[f'shot_{i}']['num_frames'] for i in (1, 2, 3)] == [121, 241, 361]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('frames,source', [(24,121),(48,121),(120,121),(121,125),(122,125),(240,241),(360,361)])
|
||||
def test_native_source_frame_rounding(frames, source):
|
||||
plan = compile_timeline(story(durations=[frames]), {})
|
||||
assert plan.shot_generation_parameters['shot_1']['num_frames'] == source
|
||||
|
||||
|
||||
@pytest.mark.parametrize('frames', [23, 361])
|
||||
def test_duration_bounds_remain_explicit(frames):
|
||||
with pytest.raises(ValidationError):
|
||||
WorkflowSpec.model_validate(story(durations=[frames]))
|
||||
|
||||
|
||||
def test_v1_still_freezes_three_five_second_shots():
|
||||
plan = compile_timeline(spec(), {})
|
||||
assert plan.frames == 360 and plan.clip_frames == 120
|
||||
assert plan.shot_frames == (120, 120, 120)
|
||||
assert all('duration_frames' not in shot for shot in plan.spec['shots'])
|
||||
assert all(p['num_frames'] == 121 for p in plan.shot_generation_parameters.values())
|
||||
invalid = spec(); invalid['shots'][0]['duration_frames'] = 360
|
||||
with pytest.raises(ValidationError):
|
||||
WorkflowSpec.model_validate(invalid)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('count',[334,1000])
|
||||
@pytest.mark.parametrize('explicit',[False,True])
|
||||
def test_long_story_total_frames_roundtrips_with_or_without_explicit_total(count,explicit):
|
||||
body=story(durations=[360]*count)
|
||||
if explicit:body['render']={'total_frames':count*360}
|
||||
accepted=WorkflowSpec.model_validate(body)
|
||||
assert accepted.render.total_frames==count*360
|
||||
encoded=accepted.model_dump(mode='json')
|
||||
reloaded=WorkflowSpec.model_validate(encoded)
|
||||
assert reloaded.model_dump(mode='json')==encoded
|
||||
|
||||
|
||||
def test_total_frames_above_maximum_story_is_rejected():
|
||||
with pytest.raises(ValidationError):
|
||||
Render.model_validate({'total_frames':360001})
|
||||
|
||||
|
||||
async def start(wf, durations, key='start'):
|
||||
response = await wf.client.post('/api/workflows', json={'spec': story(durations=durations)})
|
||||
assert response.status_code == 201, response.text
|
||||
draft = response.json()
|
||||
snapshot = await run(wf, draft, key)
|
||||
return draft, snapshot
|
||||
|
||||
|
||||
async def tick(wf):
|
||||
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
||||
|
||||
|
||||
async def test_mixed_children_freeze_independent_native_frame_counts(wf):
|
||||
_, snapshot = await start(wf, [120,240,360])
|
||||
rid = snapshot['run']['id']
|
||||
await tick(wf)
|
||||
async with wf.app.state.db.session() as session:
|
||||
parent = await session.get(WorkflowRun, rid)
|
||||
parameters = parent.spec_snapshot['compiled']['shot_generation_parameters']
|
||||
assert [parameters[f'shot_{i}']['num_frames'] for i in (1,2,3)] == [121,241,361]
|
||||
jobs = (await session.scalars(select(Job).where(Job.run_id==rid).order_by(Job.step_key))).all()
|
||||
assert [job.parameters['num_frames'] for job in jobs] == [121,241,361]
|
||||
first = parent.spec_snapshot['shots'][0]
|
||||
legacy_shot = {key:value for key,value in first.items() if key != 'duration_frames'}
|
||||
legacy_hash = digest({'shot':legacy_shot,
|
||||
'generation_parameters':parent.spec_snapshot['compiled']['generation_parameters'], 'source_sha256':None})
|
||||
step = await session.scalar(select(WorkflowStep).where(WorkflowStep.run_id==rid,WorkflowStep.step_key=='shot_1'))
|
||||
assert step.semantic_input_hash == legacy_hash
|
||||
|
||||
|
||||
@pytest.mark.parametrize('before,after', [(120,360),(360,240),(240,360)])
|
||||
async def test_source_length_revision_invalidates_reuse(wf, before, after):
|
||||
draft, first = await start(wf, [before])
|
||||
rid = first['run']['id']
|
||||
await tick(wf)
|
||||
snapshot = (await wf.client.get('/api/workflow-runs/'+rid)).json()
|
||||
jid = snapshot['steps'][0]['selected_job_id']
|
||||
assert jid is not None
|
||||
await publish_video(wf, jid)
|
||||
await wf.client.post('/api/workflow-runs/'+rid+'/cancel', json={}, headers={'Idempotency-Key':'cancel'})
|
||||
await tick(wf)
|
||||
current = (await wf.client.get('/api/workflows/'+draft['id'])).json()
|
||||
changed = await wf.client.patch('/api/workflows/'+draft['id'], json={'spec':story(durations=[after])},
|
||||
headers={'If-Match':str(current['version'])})
|
||||
assert changed.status_code == 200, changed.text
|
||||
draft = changed.json()
|
||||
response = await wf.client.post('/api/workflows/'+draft['id']+'/runs', json={
|
||||
'draft_revision':draft['revision'], 'expected_version':draft['version'], 'reuse_run_id':rid},
|
||||
headers={'Idempotency-Key':'new-source-length'})
|
||||
assert response.status_code == 202, response.text
|
||||
second = response.json()
|
||||
assert second['steps'][0]['selected_job_id'] is None
|
||||
assert second['steps'][0]['semantic_input_hash'] != first['steps'][0]['semantic_input_hash']
|
||||
await tick(wf)
|
||||
async with wf.app.state.db.session() as session:
|
||||
child = await session.scalar(select(Job).where(Job.run_id==second['run']['id']))
|
||||
assert child.parameters['num_frames'] == max(121, ((after+3)//4)*4+1)
|
||||
|
||||
|
||||
async def test_long_step_retry_keeps_frozen_length_after_draft_edit(wf):
|
||||
draft, first = await start(wf, [360])
|
||||
rid = first['run']['id']
|
||||
await tick(wf)
|
||||
async with wf.app.state.db.session() as session:
|
||||
old = await session.scalar(select(Job).where(Job.run_id==rid))
|
||||
old.state='failed'; jid=old.id
|
||||
await session.commit()
|
||||
current = (await wf.client.get('/api/workflows/'+draft['id'])).json()
|
||||
changed = await wf.client.patch('/api/workflows/'+draft['id'], json={'spec':story(durations=[240])},
|
||||
headers={'If-Match':str(current['version'])})
|
||||
assert changed.status_code == 200
|
||||
await tick(wf)
|
||||
snapshot = (await wf.client.get('/api/workflow-runs/'+rid)).json()
|
||||
response = await wf.client.post(f'/api/workflow-runs/{rid}/steps/shot_1/retry', json={
|
||||
'expected_run_version':snapshot['run']['version'], 'target_job_id':jid},
|
||||
headers={'Idempotency-Key':'retry-frozen-long'})
|
||||
assert response.status_code == 202, response.text
|
||||
selected = response.json()['steps'][0]['selected_job_id']
|
||||
async with wf.app.state.db.session() as session:
|
||||
assert (await session.get(Job, selected)).parameters['num_frames'] == 361
|
||||
assert response.json()['steps'][0]['semantic_input_hash'] == first['steps'][0]['semantic_input_hash']
|
||||
|
||||
|
||||
async def test_legacy_snapshot_without_map_keeps_original_source_parameters(wf):
|
||||
response = await wf.client.post('/api/workflows', json={'spec':spec()})
|
||||
draft = response.json(); first = await run(wf, draft)
|
||||
rid = first['run']['id']
|
||||
async with wf.app.state.db.session() as session:
|
||||
parent = await session.get(WorkflowRun, rid)
|
||||
frozen = copy.deepcopy(parent.spec_snapshot)
|
||||
frozen['compiled'].pop('shot_generation_parameters', None)
|
||||
parent.spec_snapshot = frozen
|
||||
await session.commit()
|
||||
await tick(wf)
|
||||
async with wf.app.state.db.session() as session:
|
||||
jobs = (await session.scalars(select(Job).where(Job.run_id==rid))).all()
|
||||
assert len(jobs)==3 and all(job.parameters['num_frames']==121 for job in jobs)
|
||||
assert (await session.get(WorkflowRun,rid)).spec_snapshot == frozen
|
||||
|
||||
|
||||
async def test_present_but_incomplete_generation_map_never_admits_child(wf):
|
||||
_, first = await start(wf, [120])
|
||||
rid = first['run']['id']
|
||||
async with wf.app.state.db.session() as session:
|
||||
parent = await session.get(WorkflowRun,rid)
|
||||
frozen = copy.deepcopy(parent.spec_snapshot)
|
||||
frozen['compiled']['shot_generation_parameters'] = {}
|
||||
parent.spec_snapshot = frozen
|
||||
await session.commit()
|
||||
await tick(wf)
|
||||
snapshot = (await wf.client.get('/api/workflow-runs/'+rid)).json()
|
||||
assert snapshot['run']['state']=='blocked'
|
||||
assert snapshot['jobs']==[]
|
||||
|
||||
|
||||
async def output_job(system, source_frames):
|
||||
owner = (await system.client.get('/api/auth/me')).json()['user']['id']
|
||||
job = Job(id=new_id(),owner_id=owner,task_type='video.generate',state='collecting',phase='importing_outputs',
|
||||
run_id='fixture-run',step_key='shot_1',input_json={'prompt':'fixture'},
|
||||
parameters={'num_frames':source_frames,'upscale_width':1920,'upscale_height':1056},
|
||||
request_hash='fixture',upstream_key=new_id())
|
||||
async with system.app.state.db.session() as session:
|
||||
session.add(job); await session.commit()
|
||||
return job
|
||||
|
||||
|
||||
@pytest.mark.parametrize('source_frames,decoded,accept', [(121,119,False),(121,120,True),
|
||||
(241,239,False),(241,240,True),(361,121,False),(361,359,False),(361,360,True)])
|
||||
async def test_new_workflow_output_checks_frozen_decoded_length(system, monkeypatch, source_frames, decoded, accept):
|
||||
from app import assets, media
|
||||
job = await output_job(system, source_frames)
|
||||
source = system.settings.job_work_root/job.id/'source.mp4'
|
||||
source.parent.mkdir(); source.write_bytes(b'fixture-native-video')
|
||||
async def track(*args):
|
||||
return {'frames':decoded,'fps':24,'width':1920,'height':1056,'duration':decoded/24}
|
||||
async def build(settings,owner,identifier,path,name,**fields):
|
||||
data=path.read_bytes()
|
||||
return Asset(id=identifier,owner_id=owner,name=name,storage_key=path.relative_to(settings.asset_root).as_posix(),
|
||||
kind='video',mime_type='video/mp4',size_bytes=len(data),sha256=hashlib.sha256(data).hexdigest(),
|
||||
width=1920,height=1056,duration_seconds=decoded/24,**fields)
|
||||
monkeypatch.setattr(media,'inspect_video_track',track)
|
||||
monkeypatch.setattr(assets,'build_asset',build)
|
||||
if accept:
|
||||
output=await assets.import_output(system.app.state.db,system.settings,job,source,0)
|
||||
assert output.source_job_id==job.id
|
||||
else:
|
||||
with pytest.raises(ValueError,match='frozen decoded video specification'):
|
||||
await assets.import_output(system.app.state.db,system.settings,job,source,0)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('source_frames,decoded,accept', [(121,120,True),(361,121,False),(361,360,True)])
|
||||
async def test_existing_output_recovery_rechecks_frozen_decoded_length(system,monkeypatch,source_frames,decoded,accept):
|
||||
from app import assets, media
|
||||
job=await output_job(system,source_frames)
|
||||
identifier=new_id(); path=system.settings.asset_root/job.owner_id/identifier/'original.mp4'
|
||||
path.parent.mkdir(parents=True); data=b'previously-imported';path.write_bytes(data)
|
||||
asset=Asset(id=identifier,owner_id=job.owner_id,name='output.mp4',storage_key=path.relative_to(system.settings.asset_root).as_posix(),
|
||||
kind='video',mime_type='video/mp4',size_bytes=len(data),sha256=hashlib.sha256(data).hexdigest(),
|
||||
width=1920,height=1056,duration_seconds=decoded/24,source_job_id=job.id,source_output_index=0,ready=False)
|
||||
async with system.app.state.db.session() as session:
|
||||
session.add(asset);await session.commit()
|
||||
async def track(*args):return {'frames':decoded,'fps':24,'width':1920,'height':1056,'duration':decoded/24}
|
||||
monkeypatch.setattr(media,'inspect_video_track',track)
|
||||
if accept:
|
||||
result=await assets.import_output(system.app.state.db,system.settings,job,path,0)
|
||||
assert result.id==identifier
|
||||
else:
|
||||
with pytest.raises(ValueError,match='frozen decoded video specification'):
|
||||
await assets.import_output(system.app.state.db,system.settings,job,path,0)
|
||||
|
||||
|
||||
async def test_gpu_existing_output_recovery_rejects_short_source_for_long_job(system,monkeypatch):
|
||||
from app import media
|
||||
job=await output_job(system,361)
|
||||
identifier=new_id();path=system.settings.asset_root/job.owner_id/identifier/'original.mp4'
|
||||
path.parent.mkdir(parents=True);data=b'previously-imported-short-video';path.write_bytes(data)
|
||||
async with system.app.state.db.session() as session:
|
||||
saved=await session.get(Job,job.id)
|
||||
saved.upstream_result={'outputs':[{'path':'remote.mp4'}],'metadata':{'final_output_indices':[0]}}
|
||||
session.add(Asset(id=identifier,owner_id=job.owner_id,name='short.mp4',
|
||||
storage_key=path.relative_to(system.settings.asset_root).as_posix(),kind='video',mime_type='video/mp4',
|
||||
size_bytes=len(data),sha256=hashlib.sha256(data).hexdigest(),width=1920,height=1056,
|
||||
duration_seconds=121/24,source_job_id=job.id,source_output_index=0,ready=False))
|
||||
await session.commit()
|
||||
job=saved
|
||||
async def track(*args):return {'frames':121,'fps':24,'width':1920,'height':1056,'duration':121/24}
|
||||
published=[]
|
||||
async def complete(*args,**kwargs):published.append(True)
|
||||
monkeypatch.setattr(media,'inspect_video_track',track)
|
||||
monkeypatch.setattr(system.app.state.coordinator,'_complete',complete)
|
||||
with pytest.raises(ValueError,match='frozen decoded video specification'):
|
||||
await system.app.state.coordinator._collect_gpu(job)
|
||||
assert not published
|
||||
assert system.provider.download_count==0
|
||||
|
||||
|
||||
async def test_mixed_composition_uses_exact_selected_frames_without_extension(tmp_path,monkeypatch):
|
||||
from app import media
|
||||
plan=compile_timeline(story(durations=[120,240,360]),{})
|
||||
sources=[tmp_path/f'source-{index}.mp4' for index in range(3)]
|
||||
for path in sources:path.write_bytes(b'fixture')
|
||||
calls=[]
|
||||
async def track(path,settings):
|
||||
frames=720 if path.name=='workflow.mp4' else [121,241,361][sources.index(path)]
|
||||
return {'frames':frames,'fps':24,'width':1920,'height':1080 if path.name=='workflow.mp4' else 1056,'duration':frames/24}
|
||||
async def process(argv,**kwargs):
|
||||
calls.append(argv);Path(argv[-1]).write_bytes(b'rendered');return b''
|
||||
monkeypatch.setattr(media,'inspect_video_track',track);monkeypatch.setattr(media,'run_process',process)
|
||||
result=await media.compose_workflow(plan,tmp_path/'work',settings=SimpleNamespace(
|
||||
workspace_root=tmp_path,ffmpeg_bin='ffmpeg',max_output_bytes=10**6),sources=sources)
|
||||
assert [int(call[call.index('-frames:v')+1]) for call in calls]==[120,240,360,720]
|
||||
assert result.result['frames']==720 and result.result['duration_seconds']==30
|
||||
assert all('tpad' not in ' '.join(call) and '-stream_loop' not in call for call in calls)
|
||||
|
||||
|
||||
async def test_composition_rejects_short_native_source_instead_of_extending(tmp_path,monkeypatch):
|
||||
from app import media
|
||||
plan=compile_timeline(story(durations=[360]),{})
|
||||
source=tmp_path/'source.mp4';source.write_bytes(b'fixture')
|
||||
async def track(*args):return {'frames':121,'fps':24,'width':1920,'height':1056,'duration':121/24}
|
||||
monkeypatch.setattr(media,'inspect_video_track',track)
|
||||
with pytest.raises(media.MediaError,match='360'):
|
||||
await media.compose_workflow(plan,tmp_path/'work',settings=SimpleNamespace(workspace_root=tmp_path),sources=[source])
|
||||
@ -36,7 +36,7 @@ def test_dynamic_timeline_rejects_inconsistent_order_and_bounds(change):
|
||||
if change == 'keys': body['shots'][1]['key'] = 'shot_12'
|
||||
elif change == 'duplicate': body['shots'][1]['key'] = 'shot_1'
|
||||
elif change == 'zero': body['shots'][0]['duration_frames'] = 0
|
||||
elif change == 'too_long': body['shots'][0]['duration_frames'] = 121
|
||||
elif change == 'too_long': body['shots'][0]['duration_frames'] = 361
|
||||
elif change == 'total': body['render'] = {'total_frames': 481}
|
||||
elif change == 'subtitle': body['render'] = {'subtitles': [{'start_frame': 0, 'end_frame': 481, 'text': 'bad'}]}
|
||||
else: body['render'] = {'audio': {'asset_id': 'a', 'source_start_ms': 0, 'source_end_ms': 20000, 'offset_frame': 1}}
|
||||
|
||||
@ -77,7 +77,7 @@ class ProviderTests(unittest.IsolatedAsyncioTestCase):
|
||||
self.assertEqual(payload['input']['image_path'], str(self.image))
|
||||
self.assertEqual((payload['parameters']['num_frames'], payload['parameters']['fps']), (121, 24))
|
||||
self.assertEqual(payload['parameters']['num_inference_steps'], 50)
|
||||
for parameters in ({'num_frames': 361}, {'num_frames': 120}, {'fps': 8},
|
||||
for parameters in ({'num_frames': 365}, {'num_frames': 120}, {'fps': 8},
|
||||
{'width': 1280, 'height': 736}, {'unknown': True}):
|
||||
with self.subTest(parameters=parameters), self.assertRaises(self.module.ProviderError):
|
||||
await self.provider.prepare_gpu_payload('video.generate', {'prompt': 'x'}, parameters, {}, self.work)
|
||||
@ -91,7 +91,7 @@ class ProviderTests(unittest.IsolatedAsyncioTestCase):
|
||||
('media.structure', {'asset_id': 'x'}, {'frame_count': 13}),
|
||||
('audio.speech', {'prompt': 'x'}, {'voice': '/tmp/foreign.npy'}),
|
||||
('video.compose', {}, {'clips': [{'asset_id': 'x'}], 'filter': 'unsafe'}),
|
||||
('video.generate', {'prompt': 'x'}, {'num_frames': 361}),
|
||||
('video.generate', {'prompt': 'x'}, {'num_frames': 365}),
|
||||
):
|
||||
with self.subTest(task=task), self.assertRaises(self.module.ProviderError):
|
||||
validate(task, inputs, parameters, self.settings)
|
||||
@ -209,7 +209,7 @@ class ProviderTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_capabilities_and_scheduler_do_not_overstate_or_disclose_pids(self):
|
||||
items = {item['task_type']: item for item in self.module.capabilities(self.settings)}
|
||||
self.assertFalse(items['audio.speech']['available'])
|
||||
self.assertEqual(items['video.generate']['constraints']['num_frames'], {'min': 5, 'max': 121, 'step': 4})
|
||||
self.assertEqual(items['video.generate']['constraints']['num_frames'], {'min': 5, 'max': 361, 'step': 4})
|
||||
status = {'schema_version': 1, 'generated_at': time.time(), 'error': None, 'container_id': 'b' * 64,
|
||||
'gpus': [{'index': 2, 'uuid': 'GPU-00000000-0000-0000-0000-000000000002',
|
||||
'total_gib': 79.6, 'free_gib': 79.5, 'idle_since': time.time() - 20,
|
||||
|
||||
@ -127,4 +127,5 @@ async def test_status_and_capabilities_share_live_policy_and_workflow_limits(sys
|
||||
assert body["execution_policy"]["batch_window_enabled"] is False
|
||||
assert body["execution_policy"]["configuration_error"] is None
|
||||
assert body["workflow_limits"] == {"max_shots": 240, "source_frames": 121,
|
||||
"max_clip_frames": 120, "fps": 24}
|
||||
"default_source_frames":121,"max_source_frames":361,"default_clip_frames":120,
|
||||
"max_clip_frames": 360, "fps": 24}
|
||||
|
||||
37
backend/tests/test_video_duration.py
Normal file
@ -0,0 +1,37 @@
|
||||
"""The public contract and adapter must agree on native fifteen-second shots."""
|
||||
import pytest
|
||||
|
||||
from app.providers import Provider, ProviderError, capabilities, validate_arguments
|
||||
|
||||
|
||||
def test_video_capability_exposes_fifteen_seconds_with_legacy_default(system):
|
||||
video = next(row for row in capabilities(system.settings) if row['task_type'] == 'video.generate')
|
||||
assert video['defaults']['num_frames'] == 121
|
||||
assert video['constraints']['num_frames'] == {'min': 5, 'max': 361, 'step': 4}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('frames', [241, 361])
|
||||
async def test_native_long_video_is_accepted_and_forwarded_without_shortening(system, frames):
|
||||
parameters = {'num_frames': frames, 'upscale': False}
|
||||
validate_arguments('video.generate', {'prompt': 'one continuous shot'}, parameters, system.settings)
|
||||
response = await system.client.post('/api/jobs', json={
|
||||
'task_type': 'video.generate', 'input': {'prompt': 'one continuous shot'}, 'parameters': parameters})
|
||||
assert response.status_code == 202, response.text
|
||||
assert response.json()['jobs'][0]['parameters']['num_frames'] == frames
|
||||
provider = Provider(system.settings)
|
||||
work = system.settings.job_work_root / 'longshot'
|
||||
work.mkdir(parents=True)
|
||||
try:
|
||||
payload = await provider.prepare_gpu_payload('video.generate', {'prompt': 'one continuous shot'},
|
||||
parameters, {}, work)
|
||||
assert payload['parameters']['num_frames'] == frames
|
||||
assert payload['parameters']['fps'] == 24
|
||||
finally:
|
||||
await provider.aclose()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('frames', [362, 365])
|
||||
def test_out_of_contract_video_frames_remain_rejected(system, frames):
|
||||
with pytest.raises(ProviderError):
|
||||
validate_arguments('video.generate', {'prompt': 'one continuous shot'},
|
||||
{'num_frames': frames}, system.settings)
|
||||
@ -77,7 +77,7 @@ Asset soft deletion and shared withdrawal do not promise immediate disk/quota re
|
||||
- POST `/jobs/{id}/retry` → `{jobs:Job[]}` (user requested new generation, new business ID).
|
||||
- Job: `{id,task_type,state,phase,version,prompt:string,parameters:object,input_asset_ids:string[],result_assets:Asset[],result:object|null,progress:number|null,queue_position:number|null,upstream_id:string|null,attempt_count:number,preemptions:number,last_preempted_reason:string|null,cancel_requested:boolean,error:null|{code,message,retriable},sync_warning:string|null,created_at:string,scheduled_at:string|null,started_at:string|null,finished_at:string|null}`.
|
||||
- States: `scheduled,submitting,queued,running,collecting,cancelling,succeeded,failed,cancelled,timed_out`. Remote sync failures do not invent terminal failures; set sync_warning. Requeue is the same job ID and may go running→queued.
|
||||
- Image defaults1024²/50 steps; video defaults1280×704/121frames/24fps/50steps, 1080p enhancement optional. Advanced field is exactly `num_inference_steps`. No fake generation percentage. The current web video API remains capped at121 frames (about5 seconds); native single-shot15-second server validation is not yet complete and is not a released UI capability.
|
||||
- Image defaults1024²/50 steps; video defaults1280×704/121frames/24fps/50steps, 1080p enhancement optional. Advanced field is exactly `num_inference_steps`. Video accepts5–361 integer frames with `num_frames % 4 == 1`, fixed24fps. The web duration input supports1–15 whole seconds and submits `24 * seconds + 1` frames; default5 seconds remains121 frames. A15-second native source contains361 frames (15.041667 seconds), not interpolated or slowed-down footage. No fake generation percentage.
|
||||
- ASR input accepts audio asset or video asset (CPU extract to owned WAV before upstream dispatch). Structure accepts image/video; result `subjects,scene,ocr,tags,frames?`, timestamps reflect actual sampled frames. Math result `{text}`; ASR result `{text,segments}`; composition produces video asset.
|
||||
|
||||
## Events
|
||||
@ -132,9 +132,9 @@ HTTP remains the command/query channel, SSE the owner-scoped notification channe
|
||||
|
||||
Legacy workflow spec schema1 remains exactly ordered `shot_1,shot_2,shot_3`, each `{key,prompt,image_asset_id:null|string,parameters:{seed}}`, with360 frames at24fps. Its serialization and generation hashes remain compatible.
|
||||
|
||||
Schema2 accepts1–1000 sequentially ordered `shot_N` entries with additional `duration_frames` (strict integer24–120, default120). New submissions are additionally bounded by the operator's configured shot limit. `profile=landscape_1080_v1|portrait_1080_v1`; `render={fps:24,total_frames?:integer,fit:'contain'|'cover',audio:null|{asset_id,source_start_ms,source_end_ms,offset_frame,short_policy:'silence'},subtitles:[{start_frame,end_frame,text}],template_version:'plain-v1'}`. Omitted total_frames is derived from shots; a supplied unequal value fails validation. Every model call still produces121 source frames; composition trims to each requested frame count. Audio must fit the entire dynamic timeline explicitly and subtitles use whole-film half-open frame intervals. Run total_steps is shot count+1, and steps/compose inputs follow snapshot order, including shot_10. New draft kind is multi_shot; three_shot remains accepted.
|
||||
Schema2 accepts1–1000 sequentially ordered `shot_N` entries with additional `duration_frames` (strict integer24–360, default120). New submissions are additionally bounded by the operator's configured shot limit. `profile=landscape_1080_v1|portrait_1080_v1`; `render={fps:24,total_frames?:integer,fit:'contain'|'cover',audio:null|{asset_id,source_start_ms,source_end_ms,offset_frame,short_policy:'silence'},subtitles:[{start_frame,end_frame,text}],template_version:'plain-v1'}`. Omitted total_frames is derived from shots; a supplied unequal value fails validation. Each shot generates `max(121, 4 * ceil(duration_frames / 4) + 1)` source frames and composition trims to the requested frame count. A5/10/15-second workflow requests121/241/361-frame sources and produces720 final frames (30 seconds). Schema1 retains its original3×5-second contract. Audio must fit the entire dynamic timeline explicitly and subtitles use whole-film half-open frame intervals. Run total_steps is shot count+1, and steps/compose inputs follow snapshot order, including shot_10. New draft kind is multi_shot; three_shot remains accepted.
|
||||
|
||||
Capabilities and system/status now include `workflow_limits={max_shots,source_frames:121,max_clip_frames:120,fps:24}` and `execution_policy.batch_window_enabled`, `configuration_error`, nullable `next_batch_at`. Both API and GPU worker hot-read the operator-owned RUNTIME_POLICY_FILE (default `/workspace/projects/llm-services/config/runtime-policy.json`): `{schema_version:1,batch_window_enabled:boolean,workflow_max_shots:integer1..1000}`. Missing means production defaults; malformed policy blocks new batch compute. False bypasses only the clock/window, preserves durable clock evidence and all manual/maintenance/owner/GPU priority controls. Client payloads cannot override this switch. Already admitted work finishes when the switch is re-enabled.
|
||||
Capabilities and system/status include `workflow_limits={max_shots,source_frames:121,default_source_frames:121,max_source_frames:361,default_clip_frames:120,max_clip_frames:360,fps:24}` and `execution_policy.batch_window_enabled`, `configuration_error`, nullable `next_batch_at`. `source_frames` remains a legacy default; it is not the maximum. New snapshots freeze `compiled.shot_generation_parameters` keyed by shot; legacy snapshots without that map use their original frozen shared parameters. Long-source frame counts participate in reuse/retry semantic hashes, so a short source cannot satisfy a longer shot. Both API and GPU worker hot-read the operator-owned RUNTIME_POLICY_FILE (default `/workspace/projects/llm-services/config/runtime-policy.json`): `{schema_version:1,batch_window_enabled:boolean,workflow_max_shots:integer1..1000}`. Missing means production defaults; malformed policy blocks new batch compute. False bypasses only the clock/window, preserves durable clock evidence and all manual/maintenance/owner/GPU priority controls. Client payloads cannot override this switch. Already admitted work finishes when the switch is re-enabled.
|
||||
|
||||
Manual video.compose no longer has a24-clip or1800-second final-duration cap. New commands respect the same configured clip-count limit; source cuts stay within decoded media and a86400-second source bound. Output/intermediate size, storage, process and overall execution time budgets still apply.
|
||||
|
||||
|
||||
27
docs/单镜头15秒功能与验收_20261111.md
Normal file
@ -0,0 +1,27 @@
|
||||
# 单镜头15秒功能与验收
|
||||
|
||||
当前网站为本机开发运行:前端`http://127.0.0.1:5173`,API`http://127.0.0.1:8000`。业务数据仍使用服务器MySQL,推理继续调用192.168.28.10工作区中的模型服务。
|
||||
|
||||
## 如何使用
|
||||
|
||||
进入“创作”并选择视频,在视频时长控件选择5秒、10秒或15秒,也可输入1–15的整数秒;默认仍为5秒。输入提示词、可选参考图,选择步数及画质增强后提交。网页会显示本次真实提交的源帧数:5秒为121帧、10秒为241帧、15秒为361帧,固定24fps。模型源视频多一个尾帧,因此15秒源片段实际为15.041667秒。
|
||||
|
||||
进入“工作流”,逐镜头修改选用时长,支持1–15秒,页面按0.25秒调整;JSON可以指定24–360的整数帧。每个镜头按自己的长度生成,最后裁取精确选用帧数。例如5秒、10秒、15秒三个镜头请求121、241、361源帧,合成720帧、精确30秒成片。
|
||||
|
||||
旧工作流仍按冻结参数执行,旧schema1仍为三个完整5秒镜头。5秒以内的裁剪继续使用121帧源片段,保留原先的短片复用规则;长镜头所需生成长度变化会影响复用,旧5秒源不能冒充15秒镜头。镜头顺序或长度改变后,需要重新检查字幕和音轨时间。
|
||||
|
||||
## 验证证据
|
||||
|
||||
- 浏览器实际渲染了1/5/10/15秒选择,拦截提交证明分别发送25/121/241/361帧;这些浏览器表单验收不转发GPU请求。
|
||||
- 混合5/10/15秒草稿经真实MySQL保存、重载、JSON导出/导入,始终为720帧。超出当前能力的恢复值被保留并报错,不会静默改成5秒。
|
||||
- Linux真实FFmpeg使用121、241、361帧源片段完成720帧、24fps、1920×1080、30秒输出,并完整解码。用5秒短片替代15秒输入时被拒绝,没有补帧、冻结或慢放伪造时长。
|
||||
- 正常网站API提交361帧请求后,实际经过vLLM-Omni生成与Real-ESRGAN增强,两份结果均解码为361帧、24fps、15.041667秒。该次为512×288、4步的低成本链路验收,约156.8秒;不是新的1080p质量或耗时基准。完整记录为`qa/shot15-e2e.json`。
|
||||
- 前轮1280×704、50步的原生361帧生成已完整解码通过,约817秒;本轮没有重复该高规格基准。较长镜头不保证复杂动作遵循或角色一致性。
|
||||
|
||||
浏览器记录与截图在`qa/shot15-browser.json`及`qa/shot15-*.png`;原生与增强验收样片保存在admin私有素材库,名称前缀为`15秒原生镜头端到端验收`,未发布到共享库。
|
||||
|
||||
## 运行与兼容
|
||||
|
||||
服务端runner上限从121改为361,默认121和4n+1约束保留。采用同目录原子替换供新任务读取,没有重启推理API、GPU worker、工作容器、GPU guard或共享Qwen。只重启本机网站API加载新业务合同,现有模型调度、多GPU、其他用户优先和资源保护保持原状。
|
||||
|
||||
不需要数据库迁移。新Run在JSON快照中冻结每镜头生成参数;旧快照没有新字段时继续使用原参数。工作流最大总帧数与1000个镜头、每镜头360帧保持一致;运行仍受到管理员镜头数量、存储、输出大小及执行超时约束。
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
本轮已在192.168.28.10更新网站API和前端,数据库版本为004。项目代码位于`E:\workspace\hybrid\cmvr-visual`。验收数据见`qa/v4-validation.json`和`qa/v4-browser.json`。
|
||||
|
||||
后续功能更新:单镜头15秒现已接入网页和正常接口,本文下方“网页仍约5秒”是当次容量验证结束时的历史状态。当前操作以《操作手册_20261111.md》为准,最新链路验收见《单镜头15秒功能与验收_20261111.md》。
|
||||
|
||||
## 实际数据位置
|
||||
|
||||
| 数据 | 当前存储 | 说明 |
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
| 入口 | 用途 | 输入与输出 |
|
||||
| --- | --- | --- |
|
||||
| 创作:图片 | Qwen-Image文生图 | 提示词、尺寸、种子等 → 图片 |
|
||||
| 创作:视频 | Wan单镜头文生/图生视频 | 提示词、可选参考首帧 → 约5秒以内无声片段,可选增强 |
|
||||
| 创作:视频 | Wan单镜头文生/图生视频 | 提示词、可选参考首帧 → 自选1–15秒无声片段,默认5秒,可选增强 |
|
||||
| 创作:条件样本 | SDXL+Canny ControlNet | 参考图片、提示词、控制强度 → 合成图及Canny控制图 |
|
||||
| 工作流 | 多镜头故事自动逐镜生成并合成 | 每镜头提示词/参考图/选用时长 → 一部多镜头影片 |
|
||||
| 声音 | 中文配音、Whisper转写 | 文本 → WAV;音频/有声视频 → 转写结果 |
|
||||
@ -40,10 +40,10 @@
|
||||
|
||||
1. 切换视频模式,写一个镜头中的主体动作与镜头运动。
|
||||
2. 可选择参考图片作为首帧;文生视频可不选图。
|
||||
3. 根据当前能力选择参数和1080p画质增强。当前单次接口最多121帧、24fps,约5秒;增加提示词长度不会自动延长单镜头。
|
||||
3. 在视频时长中选择5秒、10秒、15秒,或输入1–15的整数秒,默认5秒。再按需要调整参数和1080p画质增强开关。当前单次接口最多361帧、24fps;增加提示词长度不会自动延长单镜头。
|
||||
4. 需要更长故事时进入“工作流”,增加镜头;已有视频可到“成片”拼接。
|
||||
|
||||
2026-11-11已完成一次原生单镜头15秒验证:Wan2.2-TI2V-5B在1280×704、50步、24fps下一次生成361帧(15.041667秒),执行约817秒,完整解码通过;另提供只去掉末帧的360帧、精确15秒版本。帆船测试画面连续,但位移较小,不能据此保证复杂变形与强动作的效果。这是模型容量验证,网页仍开放121帧、约5秒源片段,尚未把单镜头15秒接入普通提交入口;多镜头合成时长也不等同于单镜头长度。详见同目录《存储隔离共享与15秒验证_20261111.md》。
|
||||
2026-11-11已完成一次原生单镜头15秒验证:Wan2.2-TI2V-5B在1280×704、50步、24fps下一次生成361帧(15.041667秒),执行约817秒,完整解码通过。网页现已接入最长15秒单镜头。原生源片段采用`4n+1`帧,选择15秒时输出361帧,实际约15.04秒;工作流合成会裁到选用的精确帧数。帆船测试画面连续,但位移较小,不能据此保证复杂变形与强动作的效果。较长镜头通常需要更多时间和资源,增强另有耗时。
|
||||
|
||||
### 条件样本
|
||||
|
||||
@ -56,11 +56,11 @@
|
||||
1. 打开“工作流”,点击“新建”,填写故事名称。
|
||||
2. 每个镜头填写提示词,选择种子和可选参考图片。
|
||||
3. 使用“添加镜头”增加段落;前移、后移改变顺序;删除不需要的镜头。镜头编号随当前顺序更新。
|
||||
4. 每镜头选择1–5秒的选用时长。模型当前仍按121帧生成短片段,合成只取选用帧数;缩短选用时长主要影响剪辑,不承诺同比减少GPU推理耗时。
|
||||
4. 每镜头选择1–15秒的选用时长,页面可按0.25秒调整;JSON接受24–360的整数帧。5秒以内继续生成121帧源片段再裁取,以兼容既有草稿和复用规则;超过5秒时按该镜头需要生成更长的原生片段,10秒/15秒分别生成241/361帧。不同镜头各用自己的生成长度,不会统一生成最长镜头。改变长镜头长度可能使原生成结果不再符合复用条件,需要重新生成。
|
||||
5. 选择横屏1920×1080或竖屏1080×1920。“完整画面”保留内容并留边;“填满画面”会裁切超出画布的部分。
|
||||
6. 点击“保存草稿”。刷新后可从下拉框重新打开服务器草稿。本地编辑与服务器草稿分开,导入示例不会自动保存或运行。
|
||||
|
||||
总时长由镜头选用时长相加,24fps下`总秒数=总帧数÷24`。例如4个5秒镜头为20秒,20个为100秒;不再固定为15秒。
|
||||
总时长由镜头选用时长相加,24fps下`总秒数=总帧数÷24`。例如5秒、10秒、15秒三个镜头合计30秒、720帧;20个5秒镜头合计100秒。音轨和字幕需要匹配调整后的总时长。
|
||||
|
||||
默认每工作流允许最多120镜头,可由管理员配置到1–1000。这个数量是可调整的资源保护上限,不是模型的上下文长度。磁盘、输出大小、任务数量、执行超时等限制仍有效;不承诺无限长或无限显存。
|
||||
|
||||
|
||||
@ -8,9 +8,9 @@
|
||||
|
||||
当前采用“逐镜生成短片段 → 选用所需帧 → 直切拼接 → 叠加一条旁白与人工字幕”。每镜头保持一个主要动作,使用统一形象和画风。跨镜头没有自动记忆,不能仅凭相同种子保证鲲、鹏长相一致。文本上下文长度控制提示词可包含多少信息,并不直接决定视频秒数;单次视频的帧数、显存、训练分布和动作复杂度也决定效果。
|
||||
|
||||
官方TI2V-5B支持720P、24fps文生/图生视频;本项目目前把每次生成控制在121帧,再做多镜头合成。官方说明见[Wan2.2模型卡](https://huggingface.co/Wan-AI/Wan2.2-TI2V-5B)。
|
||||
TI2V-5B以24fps生成文生/图生视频;本项目默认121帧、约5秒,页面现在支持最长361帧、约15秒原生单镜头,再按需要做多镜头合成。模型背景见[Wan2.2模型卡](https://huggingface.co/Wan-AI/Wan2.2-TI2V-5B)。
|
||||
|
||||
2026-11-11的独立帆船测试已在1280×704、50步、24fps下一次生成361帧(15.041667秒),完整解码通过;这证明当前环境可以完成该规格的15秒原生镜头,但画面移动较小,不能保证鲲鹏变形等复杂动作的效果。当前网页每次仍为121帧、24fps、约5秒源片段,普通提交尚未开放15秒单镜头;本指南的15秒小样、45秒版和100秒版都是多镜头编排。制作鲲鹏故事仍建议先做短镜头小样,逐段检查形象与动作,再合成长片。
|
||||
2026-11-11的独立帆船测试已在1280×704、50步、24fps下一次生成361帧(15.041667秒),完整解码通过;这证明当前环境可以完成该规格的15秒原生镜头,但画面移动较小,不能保证鲲鹏变形等复杂动作的效果。普通视频创作和工作流现均可选择最长15秒单镜头。工作流可混合5秒、10秒、15秒镜头,合计30秒;按动作适合的长度分配,而不是将所有镜头改为15秒。本指南现有45秒/100秒模板仍保留原先的短镜头编排。
|
||||
|
||||
## 二、准备故事原文与旁白
|
||||
|
||||
|
||||
@ -8,9 +8,9 @@
|
||||
|
||||
当前采用“逐镜生成短片段 → 选用所需帧 → 直切拼接 → 叠加一条旁白与人工字幕”。每镜头保持一个主要动作,使用统一形象和画风。跨镜头没有自动记忆,不能仅凭相同种子保证鲲、鹏长相一致。文本上下文长度控制提示词可包含多少信息,并不直接决定视频秒数;单次视频的帧数、显存、训练分布和动作复杂度也决定效果。
|
||||
|
||||
官方TI2V-5B支持720P、24fps文生/图生视频;本项目目前把每次生成控制在121帧,再做多镜头合成。官方说明见[Wan2.2模型卡](https://huggingface.co/Wan-AI/Wan2.2-TI2V-5B)。
|
||||
TI2V-5B以24fps生成文生/图生视频;本项目默认121帧、约5秒,页面现在支持最长361帧、约15秒原生单镜头,再按需要做多镜头合成。模型背景见[Wan2.2模型卡](https://huggingface.co/Wan-AI/Wan2.2-TI2V-5B)。
|
||||
|
||||
2026-11-11的独立帆船测试已在1280×704、50步、24fps下一次生成361帧(15.041667秒),完整解码通过;这证明当前环境可以完成该规格的15秒原生镜头,但画面移动较小,不能保证鲲鹏变形等复杂动作的效果。当前网页每次仍为121帧、24fps、约5秒源片段,普通提交尚未开放15秒单镜头;本指南的15秒小样、45秒版和100秒版都是多镜头编排。制作鲲鹏故事仍建议先做短镜头小样,逐段检查形象与动作,再合成长片。
|
||||
2026-11-11的独立帆船测试已在1280×704、50步、24fps下一次生成361帧(15.041667秒),完整解码通过;这证明当前环境可以完成该规格的15秒原生镜头,但画面移动较小,不能保证鲲鹏变形等复杂动作的效果。普通视频创作和工作流现均可选择最长15秒单镜头。工作流可混合5秒、10秒、15秒镜头,合计30秒;按动作适合的长度分配,而不是将所有镜头改为15秒。本指南现有45秒/100秒模板仍保留原先的短镜头编排。
|
||||
|
||||
## 二、准备故事原文与旁白
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
| 入口 | 用途 | 输入与输出 |
|
||||
| --- | --- | --- |
|
||||
| 创作:图片 | Qwen-Image文生图 | 提示词、尺寸、种子等 → 图片 |
|
||||
| 创作:视频 | Wan单镜头文生/图生视频 | 提示词、可选参考首帧 → 约5秒以内无声片段,可选增强 |
|
||||
| 创作:视频 | Wan单镜头文生/图生视频 | 提示词、可选参考首帧 → 自选1–15秒无声片段,默认5秒,可选增强 |
|
||||
| 创作:条件样本 | SDXL+Canny ControlNet | 参考图片、提示词、控制强度 → 合成图及Canny控制图 |
|
||||
| 工作流 | 多镜头故事自动逐镜生成并合成 | 每镜头提示词/参考图/选用时长 → 一部多镜头影片 |
|
||||
| 声音 | 中文配音、Whisper转写 | 文本 → WAV;音频/有声视频 → 转写结果 |
|
||||
@ -40,10 +40,10 @@
|
||||
|
||||
1. 切换视频模式,写一个镜头中的主体动作与镜头运动。
|
||||
2. 可选择参考图片作为首帧;文生视频可不选图。
|
||||
3. 根据当前能力选择参数和1080p画质增强。当前单次接口最多121帧、24fps,约5秒;增加提示词长度不会自动延长单镜头。
|
||||
3. 在视频时长中选择5秒、10秒、15秒,或输入1–15的整数秒,默认5秒。再按需要调整参数和1080p画质增强开关。当前单次接口最多361帧、24fps;增加提示词长度不会自动延长单镜头。
|
||||
4. 需要更长故事时进入“工作流”,增加镜头;已有视频可到“成片”拼接。
|
||||
|
||||
2026-11-11已完成一次原生单镜头15秒验证:Wan2.2-TI2V-5B在1280×704、50步、24fps下一次生成361帧(15.041667秒),执行约817秒,完整解码通过;另提供只去掉末帧的360帧、精确15秒版本。帆船测试画面连续,但位移较小,不能据此保证复杂变形与强动作的效果。这是模型容量验证,网页仍开放121帧、约5秒源片段,尚未把单镜头15秒接入普通提交入口;多镜头合成时长也不等同于单镜头长度。详见同目录《存储隔离共享与15秒验证_20261111.md》。
|
||||
2026-11-11已完成一次原生单镜头15秒验证:Wan2.2-TI2V-5B在1280×704、50步、24fps下一次生成361帧(15.041667秒),执行约817秒,完整解码通过。网页现已接入最长15秒单镜头。原生源片段采用`4n+1`帧,选择15秒时输出361帧,实际约15.04秒;工作流合成会裁到选用的精确帧数。帆船测试画面连续,但位移较小,不能据此保证复杂变形与强动作的效果。较长镜头通常需要更多时间和资源,增强另有耗时。
|
||||
|
||||
### 条件样本
|
||||
|
||||
@ -56,11 +56,11 @@
|
||||
1. 打开“工作流”,点击“新建”,填写故事名称。
|
||||
2. 每个镜头填写提示词,选择种子和可选参考图片。
|
||||
3. 使用“添加镜头”增加段落;前移、后移改变顺序;删除不需要的镜头。镜头编号随当前顺序更新。
|
||||
4. 每镜头选择1–5秒的选用时长。模型当前仍按121帧生成短片段,合成只取选用帧数;缩短选用时长主要影响剪辑,不承诺同比减少GPU推理耗时。
|
||||
4. 每镜头选择1–15秒的选用时长,页面可按0.25秒调整;JSON接受24–360的整数帧。5秒以内继续生成121帧源片段再裁取,以兼容既有草稿和复用规则;超过5秒时按该镜头需要生成更长的原生片段,10秒/15秒分别生成241/361帧。不同镜头各用自己的生成长度,不会统一生成最长镜头。改变长镜头长度可能使原生成结果不再符合复用条件,需要重新生成。
|
||||
5. 选择横屏1920×1080或竖屏1080×1920。“完整画面”保留内容并留边;“填满画面”会裁切超出画布的部分。
|
||||
6. 点击“保存草稿”。刷新后可从下拉框重新打开服务器草稿。本地编辑与服务器草稿分开,导入示例不会自动保存或运行。
|
||||
|
||||
总时长由镜头选用时长相加,24fps下`总秒数=总帧数÷24`。例如4个5秒镜头为20秒,20个为100秒;不再固定为15秒。
|
||||
总时长由镜头选用时长相加,24fps下`总秒数=总帧数÷24`。例如5秒、10秒、15秒三个镜头合计30秒、720帧;20个5秒镜头合计100秒。音轨和字幕需要匹配调整后的总时长。
|
||||
|
||||
默认每工作流允许最多120镜头,可由管理员配置到1–1000。这个数量是可调整的资源保护上限,不是模型的上下文长度。磁盘、输出大小、任务数量、执行超时等限制仍有效;不承诺无限长或无限显存。
|
||||
|
||||
|
||||
@ -22,7 +22,22 @@ describe('variable multi-shot contract',()=>{
|
||||
it('rejects derived-frame mismatches and durations above the clip model limit',()=>{
|
||||
const spec=story(1);spec.render.total_frames=24
|
||||
expect(()=>validateWorkflow(spec)).toThrow()
|
||||
spec.render.total_frames=121;spec.shots[0]!.duration_frames=121
|
||||
spec.render.total_frames=361;spec.shots[0]!.duration_frames=361
|
||||
expect(()=>validateWorkflow(spec)).toThrow()
|
||||
})
|
||||
it('accepts mixed5/10/15second native shots as a30second720frame timeline',()=>{
|
||||
const spec=story(3);spec.shots.forEach((shot,index)=>shot.duration_frames=[120,240,360][index]!);spec.render.total_frames=720
|
||||
expect(()=>validateWorkflow(spec)).not.toThrow()
|
||||
expect(()=> (validateWorkflow as any)(spec,120,120)).toThrow()
|
||||
})
|
||||
it('accepts arbitrary integer frame durations in v2JSON and rejects fractional frames',()=>{
|
||||
const spec=story(1);spec.shots[0]!.duration_frames=125;spec.render.total_frames=125
|
||||
expect(()=>validateWorkflow(spec)).not.toThrow()
|
||||
spec.shots[0]!.duration_frames=125.5;spec.render.total_frames=125.5
|
||||
expect(()=>validateWorkflow(spec)).toThrow()
|
||||
})
|
||||
it('does not accept explicit duration fields in legacy v1 drafts',()=>{
|
||||
const spec=story(3);spec.schema_version=1
|
||||
expect(()=>validateWorkflow(spec)).toThrow()
|
||||
})
|
||||
it('preserves legacy three-shot drafts without requiring new duration fields',()=>{
|
||||
|
||||
@ -3,6 +3,8 @@ import { ref } from 'vue'
|
||||
import { api } from '../api'
|
||||
import type { Capability, Scheduler, TaskType,ExecutionPolicy,WorkflowLimits } from '../types'
|
||||
|
||||
const legacyWorkflowLimits:WorkflowLimits={max_shots:120,source_frames:121,default_source_frames:121,max_source_frames:121,default_clip_frames:120,max_clip_frames:120,fps:24}
|
||||
|
||||
export const useCapabilitiesStore = defineStore('capabilities', () => {
|
||||
const items = ref<Capability[]>([])
|
||||
const scheduler = ref<Scheduler | null>(null)
|
||||
@ -10,12 +12,12 @@ export const useCapabilitiesStore = defineStore('capabilities', () => {
|
||||
const error = ref('')
|
||||
const inferenceOnline = ref<boolean|null>(null)
|
||||
const executionPolicy = ref<ExecutionPolicy|null>(null)
|
||||
const workflowLimits = ref<WorkflowLimits>({max_shots:120,source_frames:121,max_clip_frames:120,fps:24})
|
||||
const workflowLimits = ref<WorkflowLimits>({...legacyWorkflowLimits})
|
||||
const environment = ref<'production' | 'preview' | 'test' | null>(null)
|
||||
const databaseBackend = ref<'mysql' | 'sqlite' | null>(null)
|
||||
async function load() {
|
||||
loading.value = true
|
||||
try { const [response, status] = await Promise.all([api.capabilities(), api.systemStatus()]); items.value = response.items; scheduler.value = status.scheduler || response.scheduler; environment.value = status.environment; databaseBackend.value = status.database_backend; inferenceOnline.value=status.inference_online;executionPolicy.value=status.execution_policy||response.execution_policy||null;workflowLimits.value=status.workflow_limits||response.workflow_limits||{max_shots:120,source_frames:121,max_clip_frames:120,fps:24}; error.value = '' }
|
||||
try { const [response, status] = await Promise.all([api.capabilities(), api.systemStatus()]); items.value = response.items; scheduler.value = status.scheduler || response.scheduler; environment.value = status.environment; databaseBackend.value = status.database_backend; inferenceOnline.value=status.inference_online;executionPolicy.value=status.execution_policy||response.execution_policy||null;workflowLimits.value={...legacyWorkflowLimits,...(status.workflow_limits||response.workflow_limits||{})}; error.value = '' }
|
||||
catch (caught) { error.value = caught instanceof Error ? caught.message : '无法读取模型能力' }
|
||||
finally { loading.value = false }
|
||||
}
|
||||
|
||||
@ -1,9 +1,17 @@
|
||||
import {beforeEach,describe,expect,it,vi} from 'vitest'
|
||||
import {createPinia,setActivePinia} from 'pinia'
|
||||
import {useDraftsStore} from './drafts'
|
||||
import {emptyWorkflow,validateWorkflow} from '../v2types'
|
||||
const saved=new Map<string,string>()
|
||||
beforeEach(()=>{saved.clear();setActivePinia(createPinia());vi.stubGlobal('localStorage',{getItem:(k:string)=>saved.get(k)??null,setItem:(k:string,v:string)=>saved.set(k,v)})})
|
||||
describe('user-local draft recovery',()=>{
|
||||
it('restores native15second video parameters and mixed long workflow frame selections unchanged',()=>{
|
||||
let store=useDraftsStore();store.setOwner('alice');store.forTask('video.generate').parameters={num_frames:361,fps:24}
|
||||
const spec=emptyWorkflow();spec.shots.forEach((shot,index)=>{shot.prompt='scene';shot.duration_frames=[120,240,360][index]!});spec.render.total_frames=720
|
||||
store.page('workflow',()=>({name:'mixed',spec,draftId:'',version:0}));setActivePinia(createPinia());store=useDraftsStore();store.setOwner('alice')
|
||||
expect(store.forTask('video.generate',{num_frames:121}).parameters.num_frames).toBe(361)
|
||||
const restored=store.page<any>('workflow',()=>({}));expect(restored.spec.shots.map((shot:any)=>shot.duration_frames)).toEqual([120,240,360]);expect(()=>validateWorkflow(restored.spec)).not.toThrow()
|
||||
})
|
||||
it('restores tools and compose clips/audio/subtitles across store recreation',()=>{let s=useDraftsStore();s.setOwner('alice');s.forTask('image.generate').prompt='night garden';const compose=s.page('compose',()=>({clips:[] as string[],audio:'voice',subtitles:[{start:0,end:4,text:'hello'}]}));compose.clips.push('clip1');setActivePinia(createPinia());s=useDraftsStore();s.setOwner('alice');expect(s.forTask('image.generate').prompt).toBe('night garden');expect(s.page<any>('compose',()=>({}))).toEqual({clips:['clip1'],audio:'voice',subtitles:[{start:0,end:4,text:'hello'}]})})
|
||||
it('keeps drafts on logout but never exposes one owner to another',()=>{const s=useDraftsStore();s.setOwner('alice');s.forTask('video.generate').prompt='private';s.clear();s.setOwner('bob');expect(s.forTask('video.generate').prompt).toBe('');s.setOwner('alice');expect(s.forTask('video.generate').prompt).toBe('private')})
|
||||
it('recovers safely from invalid saved JSON',()=>{saved.set('cmvr:v2:drafts:alice','{broken');const s=useDraftsStore();s.setOwner('alice');expect(s.forTask('image.generate').prompt).toBe('')})
|
||||
|
||||
@ -32,3 +32,26 @@ export function composeFrameRates(capability?: Capability): number[] {
|
||||
export function isComposeFrameRateAllowed(value: unknown, capability?: Capability) {
|
||||
return typeof value === 'number' && composeFrameRates(capability).includes(value)
|
||||
}
|
||||
|
||||
export function videoSecondsFromFrames(value:unknown):number|null {
|
||||
return typeof value==='number'&&Number.isInteger(value)&&value>=25&&(value-1)%24===0?(value-1)/24:null
|
||||
}
|
||||
export function videoDurationBounds(capability?:Capability) {
|
||||
const constraint=capability?.constraints.num_frames
|
||||
const numeric=(value:unknown,fallback:number)=>typeof value==='number'&&Number.isInteger(value)&&value>0?value:fallback
|
||||
const minFrames=numeric(constraint?.min,5),maxFrames=numeric(constraint?.max,121),step=numeric(constraint?.step,4)
|
||||
return {minFrames,maxFrames,step,minSeconds:Math.max(1,Math.ceil((minFrames-1)/24)),maxSeconds:Math.max(0,Math.min(15,Math.floor((maxFrames-1)/24)))}
|
||||
}
|
||||
export function isVideoDurationAllowed(seconds:unknown,capability?:Capability) {
|
||||
if(typeof seconds!=='number'||!Number.isInteger(seconds)||seconds<1||seconds>15)return false
|
||||
const {minFrames,maxFrames,step}=videoDurationBounds(capability),frames=seconds*24+1
|
||||
return frames>=minFrames&&frames<=maxFrames&&(frames-minFrames)%step===0
|
||||
}
|
||||
export function videoParameters(values:Record<string,any>,capability?:Capability):Record<string,any> {
|
||||
const num_frames=values.num_frames??capability?.defaults.num_frames??121,fps=values.fps??capability?.defaults.fps??24
|
||||
if(fps!==24)throw new Error('镜头时长按 24 fps 原生生成,请先将帧率恢复为 24')
|
||||
const seconds=videoSecondsFromFrames(num_frames)
|
||||
if(seconds===null)throw new Error(`已恢复自定义帧数 ${String(num_frames)};请选择 1–15 秒的整秒时长后提交`)
|
||||
if(!isVideoDurationAllowed(seconds,capability))throw new Error(`当前环境单镜头最多支持 ${videoDurationBounds(capability).maxSeconds} 秒,请调整时长后提交`)
|
||||
return {...values,num_frames,fps}
|
||||
}
|
||||
|
||||
@ -43,5 +43,5 @@ export interface JobRequest {
|
||||
export interface Page<T> { items: T[]; total: number; page: number; page_size: number }
|
||||
export interface JobsPage extends Page<Job> { cursor: number }
|
||||
export interface ExecutionPolicy {timezone:string;start:string;end:string;batch_open:boolean;next_batch_at:string|null;close_behavior:string;batch_window_enabled:boolean;configuration_error?:string|null}
|
||||
export interface WorkflowLimits {max_shots:number;source_frames:number;max_clip_frames:number;fps:number}
|
||||
export interface WorkflowLimits {max_shots:number;source_frames:number;default_source_frames?:number;max_source_frames?:number;default_clip_frames?:number;max_clip_frames:number;fps:number}
|
||||
export interface CapabilitiesResponse { items: Capability[]; scheduler: Scheduler; execution_policy?:ExecutionPolicy;workflow_limits?:WorkflowLimits }
|
||||
|
||||
@ -17,11 +17,13 @@ export function replaceWorkflowShots(spec:WorkflowSpec,shots:WorkflowShot[]):Wor
|
||||
next.render.total_frames=workflowFrames(next);return next
|
||||
}
|
||||
export function emptyWorkflow():WorkflowSpec{return {schema_version:2,shots:Array.from({length:3},(_,index)=>createWorkflowShot(index)),profile:'landscape_1080_v1',render:{fps:24,total_frames:360,fit:'contain',audio:null,subtitles:[],template_version:'plain-v1'}}}
|
||||
export function validateWorkflow(spec:WorkflowSpec,maxShots=120){
|
||||
export function validateWorkflow(spec:WorkflowSpec,maxShots=120,maxClipFrames=360){
|
||||
if(!spec||![1,2].includes(spec.schema_version)||!Array.isArray(spec.shots)||!spec.render)throw new Error('请选择有效的工作流 JSON,版本须为 1 或 2')
|
||||
if(!Number.isInteger(maxShots)||maxShots<1||maxShots>1000)throw new Error('工作流容量配置异常,请联系管理员')
|
||||
if(!Number.isInteger(maxClipFrames)||maxClipFrames<24||maxClipFrames>360)throw new Error('工作流镜头时长配置异常,请联系管理员')
|
||||
if(spec.shots.length<1||spec.shots.length>(spec.schema_version===1?3:maxShots)||spec.schema_version===1&&spec.shots.length!==3)throw new Error(`镜头数量须为 1–${maxShots};旧版工作流固定为 3 个镜头`)
|
||||
if(spec.shots.some((s,i)=>!s||s.key!==`shot_${i+1}`||typeof s.prompt!=='string'||!s.prompt.trim()||s.prompt.length>8000||!s.parameters||!Number.isInteger(s.parameters.seed)||s.parameters.seed<0||s.parameters.seed>4294967295||(s.image_asset_id!==null&&typeof s.image_asset_id!=='string')||!Number.isInteger(s.duration_frames??120)||(s.duration_frames??120)<24||(s.duration_frames??120)>120||spec.schema_version===1&&(s.duration_frames??120)!==120))throw new Error('各镜头须填写 1–8000 字提示词、整数种子和 24–120 帧时长,并按顺序编号')
|
||||
if(spec.schema_version===1&&spec.shots.some(s=>s&&'duration_frames'in s))throw new Error('旧版工作流固定为 3 个 5 秒镜头,不支持显式 duration_frames;请使用版本 2 设置时长')
|
||||
if(spec.shots.some((s,i)=>!s||s.key!==`shot_${i+1}`||typeof s.prompt!=='string'||!s.prompt.trim()||s.prompt.length>8000||!s.parameters||!Number.isInteger(s.parameters.seed)||s.parameters.seed<0||s.parameters.seed>4294967295||(s.image_asset_id!==null&&typeof s.image_asset_id!=='string')||!Number.isInteger(s.duration_frames??120)||(s.duration_frames??120)<24||(s.duration_frames??120)>maxClipFrames))throw new Error(`各镜头须填写 1–8000 字提示词、整数种子和 24–${maxClipFrames} 帧时长,并按顺序编号`)
|
||||
const total=workflowFrames(spec)
|
||||
if(!['landscape_1080_v1','portrait_1080_v1'].includes(spec.profile)||spec.render.fps!==24||!['contain','cover'].includes(spec.render.fit)||spec.render.template_version!=='plain-v1'||spec.render.total_frames!==total)throw new Error('成片参数不合法,总帧数须等于所有镜头的帧数之和')
|
||||
if(!Array.isArray(spec.render.subtitles)||spec.render.subtitles.length>1000)throw new Error('字幕最多 1000 条')
|
||||
|
||||
27
frontend/src/videoDuration.test.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import {describe,expect,it} from 'vitest'
|
||||
import * as forms from './taskForms'
|
||||
import type {Capability} from './types'
|
||||
const video:Capability={task_type:'video.generate',label:'video',model:'Wan',available:true,input_types:['text','image'],defaults:{num_frames:121,fps:24},constraints:{num_frames:{min:5,max:361,step:4}},description:''}
|
||||
describe('native direct video duration boundary',()=>{
|
||||
it.each([[1,25],[5,121],[10,241],[15,361]])('maps %i seconds to %i native frames at24fps',(seconds,frames)=>{
|
||||
expect((forms as any).videoSecondsFromFrames(frames)).toBe(seconds)
|
||||
expect((forms as any).videoParameters({num_frames:frames,fps:24,seed:7},video)).toEqual({num_frames:frames,fps:24,seed:7})
|
||||
})
|
||||
it('keeps non-integer-second recovered frames distinguishable instead of labeling them as5seconds',()=>{
|
||||
expect((forms as any).videoSecondsFromFrames(129)).toBeNull()
|
||||
expect(()=>(forms as any).videoParameters({num_frames:129,fps:24},video)).toThrow('整秒')
|
||||
})
|
||||
it('rejects a restored15second draft when the server lowers its frame limit without modifying it',()=>{
|
||||
const saved={num_frames:361,fps:24,seed:42},limited={...video,constraints:{num_frames:{min:5,max:121,step:4}}}
|
||||
expect((forms as any).videoDurationBounds(limited).maxSeconds).toBe(5)
|
||||
expect(()=>(forms as any).videoParameters(saved,limited)).toThrow()
|
||||
expect(saved).toEqual({num_frames:361,fps:24,seed:42})
|
||||
})
|
||||
it('uses conservative5second limits when capabilities are not yet available',()=>{
|
||||
expect((forms as any).videoDurationBounds().maxSeconds).toBe(5)
|
||||
expect(()=>(forms as any).videoParameters({num_frames:361})).toThrow()
|
||||
})
|
||||
it('rejects a different playback fps rather than relabeling a15second selection',()=>{
|
||||
expect(()=>(forms as any).videoParameters({num_frames:361,fps:30},video)).toThrow('24')
|
||||
})
|
||||
})
|
||||
45
frontend/src/views/WorkbenchView.duration.test.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import {afterEach,beforeEach,describe,expect,it,vi} from 'vitest'
|
||||
import {createRenderer,h,ssrContextKey} from 'vue'
|
||||
import {createPinia,setActivePinia} from 'pinia'
|
||||
import {createMemoryHistory,createRouter} from 'vue-router'
|
||||
import {ElMessage} from 'element-plus'
|
||||
import {api} from '../api'
|
||||
import {useCapabilitiesStore} from '../stores/capabilities'
|
||||
import {useDraftsStore} from '../stores/drafts'
|
||||
import WorkbenchView from './WorkbenchView.vue'
|
||||
import type {Capability} from '../types'
|
||||
const capability:Capability={task_type:'video.generate',label:'video',model:'Wan',available:true,input_types:['text','image'],defaults:{width:1280,height:704,num_inference_steps:20,num_frames:121,fps:24,seed:42,upscale:false},constraints:{num_frames:{min:5,max:361,step:4}},description:''}
|
||||
const mounted:{unmount:()=>void}[]=[]
|
||||
beforeEach(()=>{
|
||||
vi.spyOn(api,'jobs').mockResolvedValue({items:[],total:0,page:1,page_size:20,cursor:0});vi.spyOn(api,'submit').mockResolvedValue({jobs:[]})
|
||||
for(const key of ['success','warning','error'] as const)vi.spyOn(ElMessage,key).mockImplementation(()=>({close(){}}) as any)
|
||||
})
|
||||
afterEach(()=>{mounted.splice(0).forEach(app=>app.unmount());vi.restoreAllMocks()})
|
||||
async function workbench(frames=121,maxFrames=361){
|
||||
const renderer=createRenderer<any,any>({createElement:()=>({}),createText:()=>({}),createComment:()=>({}),setText(){},setElementText(){},parentNode:()=>null,nextSibling:()=>null,patchProp(){},insert(){},remove(){}})
|
||||
const pinia=createPinia();setActivePinia(pinia)
|
||||
useCapabilitiesStore().items=[{...capability,constraints:{num_frames:{min:5,max:maxFrames,step:4}}}]
|
||||
const draft=useDraftsStore().forTask('video.generate',capability.defaults);draft.prompt='native duration';draft.parameters.num_frames=frames
|
||||
const router=createRouter({history:createMemoryHistory(),routes:[{path:'/create/:mode',component:{render:()=>null}}]});await router.push('/create/video')
|
||||
let bindings:any;const component={...WorkbenchView,setup(props:any,context:any){bindings=(WorkbenchView as any).setup(props,context);return()=>h('section')}}
|
||||
const app=renderer.createApp(component);app.use(pinia);app.use(router);app.provide(ssrContextKey,{modules:new Set()});app.mount({});mounted.push(app)
|
||||
return {bindings,draft,pinia}
|
||||
}
|
||||
describe('compiled direct native video editor',()=>{
|
||||
it('submits the selected15second native frame count rather than a retained5second default',async()=>{
|
||||
const view=await workbench();expect(typeof view.bindings.setVideoDuration).toBe('function')
|
||||
view.bindings.setVideoDuration(15);await view.bindings.submit()
|
||||
expect(vi.mocked(api.submit).mock.calls[0]?.[0]).toMatchObject({task_type:'video.generate',parameters:{num_frames:361,fps:24},count:1})
|
||||
expect(view.draft.parameters.num_frames).toBe(361)
|
||||
})
|
||||
it('refuses a restored long draft under a lowered capability without overwriting its duration',async()=>{
|
||||
const view=await workbench(361,121);await view.bindings.submit()
|
||||
expect(api.submit).not.toHaveBeenCalled();expect(view.draft.parameters.num_frames).toBe(361)
|
||||
})
|
||||
it('shows recovered custom frames and requires an explicit whole-second selection before submission',async()=>{
|
||||
const view=await workbench(129);expect(view.bindings.videoDurationLabel?.value).toContain('129 帧')
|
||||
await view.bindings.submit();expect(api.submit).not.toHaveBeenCalled();expect(view.draft.parameters.num_frames).toBe(129)
|
||||
view.bindings.setVideoDuration(10);await view.bindings.submit()
|
||||
expect(vi.mocked(api.submit).mock.calls[0]?.[0].parameters.num_frames).toBe(241)
|
||||
})
|
||||
})
|
||||
@ -9,6 +9,7 @@ import { useJobsStore } from '../stores/jobs'
|
||||
import { useAssetsStore } from '../stores/assets'
|
||||
import {useTaskHistory} from '../composables/taskHistory'
|
||||
import { errorMessage } from '../api'
|
||||
import {videoSecondsFromFrames,videoDurationBounds,isVideoDurationAllowed,videoParameters} from '../taskForms'
|
||||
import { inspirations } from '../inspirations'
|
||||
import type { Asset, TaskType } from '../types'
|
||||
import AssetInput from '../components/AssetInput.vue'
|
||||
@ -20,6 +21,15 @@ const mode = computed(() => ['image', 'video', 'defect'].includes(String(route.p
|
||||
const taskType = computed<TaskType>(() => mode.value === 'video' ? 'video.generate' : mode.value === 'defect' ? 'defect.generate' : 'image.generate')
|
||||
const capability = computed(() => capabilities.forTask(taskType.value))
|
||||
const draft = computed(() => drafts.forTask(taskType.value, capability.value?.defaults))
|
||||
const rawVideoFrames=computed(()=>draft.value.parameters.num_frames??capability.value?.defaults.num_frames??121)
|
||||
const videoSeconds=computed(()=>videoSecondsFromFrames(rawVideoFrames.value)),videoBounds=computed(()=>videoDurationBounds(capability.value))
|
||||
const videoDurationLabel=computed(()=>{
|
||||
const fps=draft.value.parameters.fps??capability.value?.defaults.fps??24
|
||||
if(fps!==24)return `${String(rawVideoFrames.value)} 帧 · ${String(fps)} fps(待调整)`
|
||||
return videoSeconds.value!==null?`${videoSeconds.value} 秒 · ${rawVideoFrames.value} 帧`:typeof rawVideoFrames.value==='number'&&Number.isFinite(rawVideoFrames.value)?`${rawVideoFrames.value} 帧 · 约 ${(rawVideoFrames.value/24).toFixed(2)} 秒`:`自定义帧数 ${String(rawVideoFrames.value)}`
|
||||
})
|
||||
const videoDurationWarning=computed(()=>{if(mode.value!=='video')return '';try{videoParameters(draft.value.parameters,capability.value);return ''}catch(error){return errorMessage(error)}})
|
||||
function setVideoDuration(seconds:number){if(!isVideoDurationAllowed(seconds,capability.value)){ElMessage.warning(`请选择当前环境支持的 ${videoBounds.value.minSeconds}–${videoBounds.value.maxSeconds} 秒整秒时长`);return}draft.value.parameters.num_frames=seconds*24+1;draft.value.parameters.fps=24}
|
||||
const reference = computed({ get: () => draft.value.imageAssetId ? assets.byId[draft.value.imageAssetId] || null : null, set: (asset: Asset | null) => { draft.value.imageAssetId = asset?.id || null } })
|
||||
const history=useTaskHistory(taskType,18), recentJobs=history.items
|
||||
const busy = ref(false), importing = ref<string | null>(null), selectedAsset = ref<Asset | null>(null), detailId = ref<string | null>(null), textarea = ref<HTMLTextAreaElement>()
|
||||
@ -41,12 +51,14 @@ async function submit() {
|
||||
const p = draft.value.parameters
|
||||
if (![p.width, p.height, p.num_inference_steps].every(value => Number.isFinite(value) && value > 0)) { ElMessage.warning('请补全尺寸和生成步数'); return }
|
||||
if (capability.value.constraints.max_pixels && p.width * p.height > capability.value.constraints.max_pixels) { ElMessage.warning('当前尺寸超过模型支持的像素上限'); return }
|
||||
let parameters=p
|
||||
if(mode.value==='video'){try{parameters=videoParameters(p,capability.value)}catch(error){ElMessage.warning(errorMessage(error));return}}
|
||||
busy.value = true
|
||||
try {
|
||||
const input: Record<string, any> = { prompt: draft.value.prompt.trim() }
|
||||
if (draft.value.negative_prompt.trim()) input.negative_prompt = draft.value.negative_prompt.trim()
|
||||
if (reference.value && mode.value !== 'image') input.image_asset_id = reference.value.id
|
||||
const created = await jobs.submit({ task_type: taskType.value, input, parameters: { ...p }, count: mode.value === 'video' ? 1 : draft.value.count, scheduled_at: draft.value.scheduledAt ? new Date(draft.value.scheduledAt).toISOString() : null })
|
||||
const created = await jobs.submit({ task_type: taskType.value, input, parameters: { ...parameters }, count: mode.value === 'video' ? 1 : draft.value.count, scheduled_at: draft.value.scheduledAt ? new Date(draft.value.scheduledAt).toISOString() : null })
|
||||
void history.load();ElMessage.success(`已加入 ${created.length} 项创作任务`)
|
||||
} catch (error) { ElMessage.error(errorMessage(error)) } finally { busy.value = false }
|
||||
}
|
||||
@ -75,10 +87,11 @@ onMounted(() => { void jobs.refresh().catch(() => undefined); void importReferen
|
||||
<section class="composer-wrap"><div class="prompt-composer">
|
||||
<AssetInput v-if="mode !== 'image'" v-model="reference" :kinds="['image']" :label="mode === 'video' ? '添加首帧(可选)' : '添加参考图片'" :hint="mode === 'video' ? '文生视频可不添加图片' : '上传图片,用边缘结构约束生成'" />
|
||||
<textarea ref="textarea" v-model="draft.prompt" :placeholder="placeholder" maxlength="8000" aria-label="创作提示词" @keydown.ctrl.enter.prevent="submit" @keydown.meta.enter.prevent="submit" />
|
||||
<p v-if="mode==='video'&&videoDurationWarning" class="notice warning">{{ videoDurationWarning }}</p>
|
||||
<div class="composer-controls"><div class="composer-parameters"><span class="model-chip"><span class="model-mark">M</span>{{ capability?.model || '正在读取模型' }}</span>
|
||||
<el-popover placement="top-start" :width="310" trigger="click"><template #reference><button class="parameter-chip">{{ draft.parameters.width || '—' }} × {{ draft.parameters.height || '—' }}</button></template><div class="parameter-form"><h3>画面尺寸</h3><div v-if="mode !== 'video'" class="ratio-options"><button @click="ratio(1024, 1024)">1:1</button><button @click="ratio(1280, 720)">16:9</button><button @click="ratio(720, 1280)">9:16</button></div><label>宽度<el-input-number v-model="draft.parameters.width" :min="bound('width','min',256)" :max="bound('width','max',2048)" :step="bound('width','step',16)" /></label><label>高度<el-input-number v-model="draft.parameters.height" :min="bound('height','min',256)" :max="bound('height','max',2048)" :step="bound('height','step',16)" /></label></div></el-popover>
|
||||
<span v-if="mode === 'video'" class="parameter-chip">约 5 秒 · 121 帧 · 24 fps</span><el-select v-else v-model="draft.count" class="count-select" aria-label="生成数量"><el-option v-for="count in bound('count','max',4)" :key="count" :value="count" :label="`${count} 张`" /></el-select>
|
||||
<el-popover trigger="click" placement="top" :width="340"><template #reference><button class="parameter-chip"><el-icon><Setting /></el-icon>参数</button></template><div class="parameter-form"><h3>生成参数</h3><label>步数<el-input-number v-model="draft.parameters.num_inference_steps" :min="bound('num_inference_steps','min',1)" :max="bound('num_inference_steps','max',100)" /></label><label v-if="draft.parameters.seed !== undefined">随机种子<el-input-number v-model="draft.parameters.seed" :min="0" :max="4294967295" :controls="false" /></label><label v-if="draft.parameters.guidance_scale !== undefined">引导强度<el-input-number v-model="draft.parameters.guidance_scale" :min="bound('guidance_scale','min',1)" :max="bound('guidance_scale','max',20)" :step="0.5" /></label><template v-if="mode === 'defect'"><label>结构控制强度<el-input-number v-model="draft.parameters.controlnet_conditioning_scale" :min="0" :max="2" :step="0.1" /></label><label>Canny低阈值<el-input-number v-model="draft.parameters.canny_low" :min="0" :max="254" /></label><label>Canny高阈值<el-input-number v-model="draft.parameters.canny_high" :min="1" :max="255" /></label></template><label v-if="mode === 'video'">1080p 画质增强<el-switch v-model="draft.parameters.upscale" /></label><label class="vertical-label">不希望出现的内容<el-input v-model="draft.negative_prompt" maxlength="8000" type="textarea" :rows="2" placeholder="可选,例如模糊、变形" /></label><small v-if="mode === 'defect'">输出合成图和 Canny 控制图,不提供缺陷真值掩膜。</small><small v-if="mode === 'video'">单镜头最长约 5 秒;较长故事请前往工作流添加多个镜头。</small></div></el-popover>
|
||||
<el-popover v-if="mode === 'video'" placement="top-start" :width="340" trigger="click"><template #reference><button class="parameter-chip" aria-label="设置镜头时长">镜头时长 · {{ videoDurationLabel }}</button></template><div class="parameter-form"><h3>原生镜头时长</h3><label>时长(整秒)<el-select :model-value="videoSeconds??undefined" placeholder="选择整秒时长" aria-label="镜头时长(秒)" @change="setVideoDuration"><el-option v-for="seconds in 15" :key="seconds" :value="seconds" :label="`${seconds} 秒`" :disabled="!isVideoDurationAllowed(seconds,capability)"/></el-select></label><div class="ratio-options"><button v-for="seconds in [5,10,15]" :key="seconds" :disabled="!isVideoDurationAllowed(seconds,capability)" @click="setVideoDuration(seconds)">{{ seconds }} 秒</button></div><small>当前环境支持 {{ videoBounds.minSeconds }}–{{ videoBounds.maxSeconds }} 秒。按 24 fps 原生生成,源片段比所选整秒多 1 帧。</small><p v-if="videoDurationWarning" class="notice warning">{{ videoDurationWarning }}</p></div></el-popover><el-select v-else v-model="draft.count" class="count-select" aria-label="生成数量"><el-option v-for="count in bound('count','max',4)" :key="count" :value="count" :label="`${count} 张`" /></el-select>
|
||||
<el-popover trigger="click" placement="top" :width="340"><template #reference><button class="parameter-chip"><el-icon><Setting /></el-icon>参数</button></template><div class="parameter-form"><h3>生成参数</h3><label>步数<el-input-number v-model="draft.parameters.num_inference_steps" :min="bound('num_inference_steps','min',1)" :max="bound('num_inference_steps','max',100)" /></label><label v-if="draft.parameters.seed !== undefined">随机种子<el-input-number v-model="draft.parameters.seed" :min="0" :max="4294967295" :controls="false" /></label><label v-if="draft.parameters.guidance_scale !== undefined">引导强度<el-input-number v-model="draft.parameters.guidance_scale" :min="bound('guidance_scale','min',1)" :max="bound('guidance_scale','max',20)" :step="0.5" /></label><template v-if="mode === 'defect'"><label>结构控制强度<el-input-number v-model="draft.parameters.controlnet_conditioning_scale" :min="0" :max="2" :step="0.1" /></label><label>Canny低阈值<el-input-number v-model="draft.parameters.canny_low" :min="0" :max="254" /></label><label>Canny高阈值<el-input-number v-model="draft.parameters.canny_high" :min="1" :max="255" /></label></template><label v-if="mode === 'video'">1080p 画质增强<el-switch v-model="draft.parameters.upscale" /></label><label class="vertical-label">不希望出现的内容<el-input v-model="draft.negative_prompt" maxlength="8000" type="textarea" :rows="2" placeholder="可选,例如模糊、变形" /></label><small v-if="mode === 'defect'">输出合成图和 Canny 控制图,不提供缺陷真值掩膜。</small><small v-if="mode === 'video'">单镜头可选 {{ videoBounds.minSeconds }}–{{ videoBounds.maxSeconds }} 秒原生时长;需要多个镜头时请前往工作流编排。</small></div></el-popover>
|
||||
<el-popover trigger="click" placement="top" :width="300"><template #reference><button class="parameter-chip" :class="{ highlighted: draft.scheduledAt }"><el-icon><Clock /></el-icon>{{ draft.scheduledAt ? '已预约' : '预约' }}</button></template><div class="parameter-form"><h3>预约创作</h3><el-date-picker v-model="draft.scheduledAt" type="datetime" placeholder="选择开始时间" value-format="YYYY-MM-DDTHH:mm:ss" clearable /><small>按当前浏览器时区选择。到达时间后按就绪顺序等待空闲GPU。</small></div></el-popover>
|
||||
</div><el-button class="generate-button" type="primary" :loading="busy" :disabled="!capability?.available" :icon="MagicStick" @click="submit">{{ draft.scheduledAt ? '预约生成' : '开始生成' }} <el-icon v-if="!busy"><ArrowRight /></el-icon></el-button></div>
|
||||
</div><div class="composer-footnote"><span>{{ capability?.available ? '空闲GPU并行执行 · 先到先派发 · 外部占卡时让行' : capability?.description || '正在连接本地创作服务' }}</span><span>Ctrl + Enter 生成</span></div></section>
|
||||
|
||||
@ -1,27 +1,58 @@
|
||||
import {afterEach,describe,expect,it,vi} from 'vitest'
|
||||
import {beforeEach,afterEach,describe,expect,it,vi} from 'vitest'
|
||||
import {createSSRApp,defineComponent,h} from 'vue'
|
||||
import {renderToString} from 'vue/server-renderer'
|
||||
import {createPinia,setActivePinia} from 'pinia'
|
||||
import {useDraftsStore} from '../stores/drafts'
|
||||
import {useCapabilitiesStore} from '../stores/capabilities'
|
||||
import {ElMessage,ElMessageBox} from 'element-plus'
|
||||
import {api} from '../api'
|
||||
import {emptyWorkflow,replaceWorkflowShots,validateWorkflow} from '../v2types'
|
||||
import type {WorkflowSpec} from '../v2types'
|
||||
import WorkflowView from './WorkflowView.vue'
|
||||
const assetSelections=vi.hoisted(()=>[] as ((asset:any)=>unknown)[])
|
||||
vi.mock('../components/AssetPicker.vue',async()=>{const {defineComponent}=await import('vue');return {default:defineComponent({setup(_,{attrs}){if(typeof attrs.onSelect==='function')assetSelections.push(attrs.onSelect as (asset:any)=>unknown);return()=>null}})}})
|
||||
vi.mock('../components/RunCard.vue',()=>({default:{render:()=>null}}))
|
||||
beforeEach(()=>{for(const key of ['success','warning','error'] as const)vi.spyOn(ElMessage,key).mockImplementation(()=>({close(){}}) as any)})
|
||||
afterEach(()=>vi.restoreAllMocks())
|
||||
async function editor(spec:WorkflowSpec){
|
||||
async function editor(spec:WorkflowSpec,maxClipFrames=360){
|
||||
assetSelections.length=0
|
||||
const pinia=createPinia();setActivePinia(pinia)
|
||||
useCapabilitiesStore().workflowLimits={max_shots:120,source_frames:121,max_clip_frames:maxClipFrames,fps:24}
|
||||
const local=useDraftsStore().page('workflow',()=>({name:'故事',spec,draftId:'',version:0}))
|
||||
const buttons:{label:string;click:()=>unknown}[]=[],changes:((value:number)=>unknown)[]=[]
|
||||
const app=createSSRApp(WorkflowView);app.use(pinia)
|
||||
const buttons:{label:string;click:()=>unknown}[]=[],changes:((value:number)=>unknown)[]=[],durationMaxima:number[]=[];let bindings:any
|
||||
const component={...WorkflowView,setup(props:any,context:any){bindings=(WorkflowView as any).setup(props,context);return bindings}}
|
||||
const app=createSSRApp(component);app.use(pinia)
|
||||
app.component('ElButton',defineComponent({setup(_,{attrs,slots}){const nodes=slots.default?.()||[],label=nodes.map(n=>typeof n.children==='string'?n.children:'').join('');if(typeof attrs.onClick==='function')buttons.push({label,click:attrs.onClick as ()=>unknown});return()=>h('button',nodes)}}))
|
||||
app.component('ElInputNumber',defineComponent({setup(_,{attrs}){if(typeof attrs.onChange==='function')changes.push(attrs.onChange as (value:number)=>unknown);return()=>null}}))
|
||||
app.component('ElInputNumber',defineComponent({setup(_,{attrs}){if(typeof attrs.onChange==='function'){changes.push(attrs.onChange as (value:number)=>unknown);durationMaxima.push(attrs.max as number)}return()=>null}}))
|
||||
for(const name of ['ElInput','ElSelect','ElOption'])app.component(name,defineComponent({setup(_,{slots}){return()=>h('div',slots.default?.())}}))
|
||||
return {html:await renderToString(app),local,buttons,changes}
|
||||
return {html:await renderToString(app),local,buttons,changes,durationMaxima,bindings}
|
||||
}
|
||||
describe('compiled variable workflow editor',()=>{
|
||||
it('edits mixed5/10/15second shots without trimming the long selections',async()=>{
|
||||
const spec=emptyWorkflow();spec.shots.forEach(s=>s.prompt='scene')
|
||||
const view=await editor(spec);expect(view.durationMaxima).toEqual([15,15,15]);view.changes[1]!(10);view.changes[2]!(15)
|
||||
expect(view.local.spec.shots.map(s=>s.duration_frames)).toEqual([120,240,360]);expect(view.local.spec.render.total_frames).toBe(720)
|
||||
const restored=await editor(view.local.spec);expect(restored.html).toContain('3 个镜头 · 720 帧 · 30.00 秒')
|
||||
})
|
||||
it('imports a long v2JSON only into the local editor without submitting it',async()=>{
|
||||
const incoming=emptyWorkflow();incoming.shots.forEach((shot,index)=>{shot.prompt='scene';shot.duration_frames=[120,240,360][index]!});incoming.render.total_frames=720
|
||||
vi.spyOn(ElMessageBox,'confirm').mockResolvedValue('confirm' as any);const create=vi.spyOn(api,'createWorkflow')
|
||||
const view=await editor(emptyWorkflow()),input={files:[{size:300,name:'mixed.json',text:async()=>JSON.stringify(incoming)}],value:'file'}
|
||||
await view.bindings.importFile({target:input})
|
||||
expect(view.local.spec.shots.map(s=>s.duration_frames)).toEqual([120,240,360]);expect(view.local.spec.render.total_frames).toBe(720);expect(view.local.draftId).toBe('');expect(create).not.toHaveBeenCalled()
|
||||
})
|
||||
it('blocks longJSON import when the advertised clip limit remains5seconds',async()=>{
|
||||
const incoming=emptyWorkflow();incoming.shots.forEach(shot=>{shot.prompt='scene';shot.duration_frames=360});incoming.render.total_frames=1080
|
||||
const view=await editor(emptyWorkflow(),120),original=JSON.stringify(view.local.spec),input={files:[{size:300,name:'too-long.json',text:async()=>JSON.stringify(incoming)}],value:'file'}
|
||||
await view.bindings.importFile({target:input})
|
||||
expect(JSON.stringify(view.local.spec)).toBe(original);expect(ElMessage.error).toHaveBeenCalledWith(expect.stringContaining('24–120'))
|
||||
})
|
||||
it('preserves restored long shots but refuses save under a lowered clip limit',async()=>{
|
||||
const spec=emptyWorkflow();spec.shots.forEach((shot,index)=>{shot.prompt='scene';shot.duration_frames=[120,240,360][index]!});spec.render.total_frames=720
|
||||
const create=vi.spyOn(api,'createWorkflow'),view=await editor(spec,120)
|
||||
await view.buttons.find(button=>button.label==='保存草稿')!.click()
|
||||
expect(create).not.toHaveBeenCalled();expect(view.local.spec.shots.map(s=>s.duration_frames)).toEqual([120,240,360]);expect(view.html).toContain('原内容已保留')
|
||||
})
|
||||
it('shows a100-second story and exposes explicit import/export without submitting it',async()=>{
|
||||
const spec=emptyWorkflow();spec.shots=Array.from({length:20},(_,i)=>({...spec.shots[0]!,key:`shot_${i+1}`,prompt:`画面${i+1}`}));spec.render.total_frames=2400
|
||||
const view=await editor(spec)
|
||||
|
||||
46
frontend/src/views/WorkflowView.timeline.test.ts
Normal file
@ -0,0 +1,46 @@
|
||||
import {afterEach,beforeEach,describe,expect,it,vi} from 'vitest'
|
||||
import {createSSRApp,defineComponent,h} from 'vue'
|
||||
import {renderToString} from 'vue/server-renderer'
|
||||
import {createPinia,setActivePinia} from 'pinia'
|
||||
import {ElInputNumber,ElMessage,ID_INJECTION_KEY} from 'element-plus'
|
||||
import {useDraftsStore} from '../stores/drafts'
|
||||
import {useCapabilitiesStore} from '../stores/capabilities'
|
||||
import {emptyWorkflow,replaceWorkflowShots,validateWorkflow} from '../v2types'
|
||||
import {api} from '../api'
|
||||
import WorkflowView from './WorkflowView.vue'
|
||||
vi.mock('../components/AssetPicker.vue',()=>({default:{render:()=>null}}))
|
||||
vi.mock('../components/RunCard.vue',()=>({default:{render:()=>null}}))
|
||||
beforeEach(()=>{for(const key of ['success','warning','error'] as const)vi.spyOn(ElMessage,key).mockImplementation(()=>({close(){}}) as any)})
|
||||
afterEach(()=>vi.restoreAllMocks())
|
||||
async function render(pinia:ReturnType<typeof createPinia>){
|
||||
const buttons:{label:string;click:()=>unknown}[]=[],app=createSSRApp(WorkflowView);app.use(pinia);app.provide(ID_INJECTION_KEY,{prefix:100,current:0})
|
||||
// Keep Element Plus's actual immediate model-value watcher; it used to clamp restored values.
|
||||
app.component('ElInputNumber',ElInputNumber)
|
||||
app.component('ElButton',defineComponent({setup(_,{slots,attrs}){const children=slots.default?.()||[],label=children.map(node=>typeof node.children==='string'?node.children:'').join('');if(typeof attrs.onClick==='function')buttons.push({label,click:attrs.onClick as ()=>unknown});return()=>h('button',children)}}))
|
||||
for(const name of ['ElInput','ElSelect','ElOption'])app.component(name,defineComponent({setup(_,{slots}){return()=>h('div',slots.default?.())}}))
|
||||
return {html:await renderToString(app),buttons}
|
||||
}
|
||||
function timeline(){
|
||||
const pinia=createPinia();setActivePinia(pinia);useCapabilitiesStore().workflowLimits={max_shots:120,source_frames:121,max_clip_frames:360,fps:24}
|
||||
const spec=emptyWorkflow();spec.shots=[{...spec.shots[0]!,prompt:'scene',duration_frames:360}];spec.render.total_frames=360
|
||||
spec.render.subtitles=[{start_frame:240,end_frame:360,text:'ending'}]
|
||||
spec.render.audio={asset_id:'voice',source_start_ms:0,source_end_ms:1000,offset_frame:300,short_policy:'silence'}
|
||||
const local=useDraftsStore().page('workflow',()=>({name:'timeline',spec,draftId:'',version:0}));return {pinia,local}
|
||||
}
|
||||
describe('real Element Plus timeline controls preserve invalid restored values',()=>{
|
||||
it('retains subtitle240/360 and audio offset300 after15seconds is shortened to5and remounted',async()=>{
|
||||
const {pinia,local}=timeline();await render(pinia)
|
||||
local.spec=replaceWorkflowShots(local.spec,[{...local.spec.shots[0]!,duration_frames:120}])
|
||||
const create=vi.spyOn(api,'createWorkflow'),view=await render(pinia)
|
||||
expect(local.spec.render.subtitles).toEqual([{start_frame:240,end_frame:360,text:'ending'}]);expect(local.spec.render.audio?.offset_frame).toBe(300)
|
||||
expect(view.html).toContain('字幕超出当前成片');expect(()=>validateWorkflow(local.spec)).toThrow()
|
||||
await view.buttons.find(button=>button.label==='保存草稿')!.click();expect(create).not.toHaveBeenCalled();expect(ElMessage.error).toHaveBeenCalled()
|
||||
})
|
||||
it('does not normalize out-of-range source times or negative restored timeline boundaries',async()=>{
|
||||
const {pinia,local}=timeline();local.spec.render.audio={asset_id:'voice',source_start_ms:-1,source_end_ms:86400001,offset_frame:-2,short_policy:'silence'}
|
||||
local.spec.render.subtitles=[{start_frame:-24,end_frame:-1,text:'invalid'}]
|
||||
await render(pinia)
|
||||
expect(local.spec.render.audio).toEqual({asset_id:'voice',source_start_ms:-1,source_end_ms:86400001,offset_frame:-2,short_policy:'silence'})
|
||||
expect(local.spec.render.subtitles).toEqual([{start_frame:-24,end_frame:-1,text:'invalid'}]);expect(()=>validateWorkflow(local.spec)).toThrow()
|
||||
})
|
||||
})
|
||||
@ -17,24 +17,27 @@ const busy=ref(false),picker=ref(false),pickShot=ref(0),audioPicker=ref(false),f
|
||||
const drafts=computed(()=>Object.values(store.drafts).sort((a,b)=>b.updated_at.localeCompare(a.updated_at)))
|
||||
const draft=computed(()=>store.drafts[local.draftId])
|
||||
const runs=computed(()=>Object.values(store.runs).filter(x=>x.run.draft_id===local.draftId).sort((a,b)=>b.run.created_at.localeCompare(a.run.created_at)))
|
||||
const maxClipFrames=computed(()=>caps.workflowLimits.max_clip_frames),maxClipSeconds=computed(()=>maxClipFrames.value/24)
|
||||
const maxShots=computed(()=>caps.workflowLimits.max_shots),totalFrames=computed(()=>workflowFrames(local.spec)),totalSeconds=computed(()=>totalFrames.value/24)
|
||||
const shotRanges=computed(()=>{let start=0;return local.spec.shots.map(shot=>{const range={start,end:start+(shot.duration_frames??120)};start=range.end;return range})})
|
||||
const subtitleInvalid=computed(()=>local.spec.render.subtitles.some(row=>!Number.isInteger(row.start_frame)||!Number.isInteger(row.end_frame)||row.start_frame<0||row.end_frame>totalFrames.value||row.end_frame<=row.start_frame))
|
||||
const audioInvalid=computed(()=>{const a=local.spec.render.audio;return !!a&&(![a.source_start_ms,a.source_end_ms,a.offset_frame].every(Number.isInteger)||a.source_start_ms<0||a.source_end_ms>86400000||a.source_end_ms<=a.source_start_ms||a.offset_frame<0)})
|
||||
const audioOverflow=computed(()=>{const a=local.spec.render.audio;return !!a&&(a.source_end_ms-a.source_start_ms)*24/1000+a.offset_frame>totalFrames.value})
|
||||
let synchronizing=false
|
||||
// Opening legacy data preserves it. Editing upgrades it to the variable timeline.
|
||||
watch(()=>local.spec,spec=>{if(synchronizing)return;synchronizing=true;try{if(spec.schema_version===1)local.spec=replaceWorkflowShots(spec,spec.shots);else if(spec.render.total_frames!==workflowFrames(spec))spec.render.total_frames=workflowFrames(spec)}finally{synchronizing=false}},{deep:true,flush:'sync'})
|
||||
function choose(value:DraftDTO){synchronizing=true;try{local.name=value.name;local.spec=JSON.parse(JSON.stringify(value.spec));local.draftId=value.id;local.version=value.version}finally{synchronizing=false}}
|
||||
async function load(id:string){if(!id)return;try{const loaded=await store.fetchDraft(id);if(loaded)choose(loaded)}catch(e){ElMessage.error(errorMessage(e))}}
|
||||
async function save(session:number){if(session!==store.sessionId())return;if(!local.name.trim()||local.name.length>255)throw new Error('名称须为 1–255 字');validateWorkflow(local.spec,maxShots.value);const current=draft.value;if(current&¤t.version!==local.version)throw new Error('服务端草稿已更新,请重新载入后再编辑,当前本地内容仍保留');if(current&¤t.name===local.name&&JSON.stringify(current.spec)===JSON.stringify(local.spec))return current;const saved=await store.saveDraft(current?{...current,version:local.version}:undefined,local.name,local.spec,session);if(saved)choose(saved);return saved}
|
||||
async function save(session:number){if(session!==store.sessionId())return;if(!local.name.trim()||local.name.length>255)throw new Error('名称须为 1–255 字');validateWorkflow(local.spec,maxShots.value,maxClipFrames.value);const current=draft.value;if(current&¤t.version!==local.version)throw new Error('服务端草稿已更新,请重新载入后再编辑,当前本地内容仍保留');if(current&¤t.name===local.name&&JSON.stringify(current.spec)===JSON.stringify(local.spec))return current;const saved=await store.saveDraft(current?{...current,version:local.version}:undefined,local.name,local.spec,session);if(saved)choose(saved);return saved}
|
||||
async function act(run=false){if(busy.value)return;busy.value=true;const session=store.sessionId();try{const saved=await save(session);if(!saved)return;if(run){const snapshot=await store.startRun(saved,reuse.value||undefined,session);if(!snapshot)return;if(snapshot.draft)choose(snapshot.draft);ElMessage.success('工作流已提交')}else ElMessage.success('草稿已保存')}catch(e){ElMessage.error(errorMessage(e))}finally{busy.value=false}}
|
||||
function fresh(){synchronizing=true;try{local.name='多镜头故事';local.spec=emptyWorkflow();local.draftId='';local.version=0;reuse.value=''}finally{synchronizing=false}}
|
||||
function addShot(){if(local.spec.shots.length>=maxShots.value)return;local.spec=replaceWorkflowShots(local.spec,[...local.spec.shots,createWorkflowShot(local.spec.shots.length)])}
|
||||
function removeShot(index:number){if(local.spec.shots.length<=1)return;local.spec=replaceWorkflowShots(local.spec,local.spec.shots.filter((_,i)=>i!==index))}
|
||||
function moveShot(index:number,target:number){if(target<0||target>=local.spec.shots.length)return;const shots=[...local.spec.shots],shot=shots.splice(index,1)[0];if(shot){shots.splice(target,0,shot);local.spec=replaceWorkflowShots(local.spec,shots)}}
|
||||
function setDuration(index:number,seconds:number|undefined){if(!local.spec.shots[index]||seconds===undefined||!Number.isFinite(seconds))return;const frames=Math.max(24,Math.min(120,Math.round(seconds*24)));local.spec=replaceWorkflowShots(local.spec,local.spec.shots.map((shot,i)=>i===index?{...shot,duration_frames:frames}:shot))}
|
||||
function setDuration(index:number,seconds:number|undefined){if(!local.spec.shots[index]||seconds===undefined||!Number.isFinite(seconds))return;const frames=Math.round(seconds*24);if(frames<24||frames>maxClipFrames.value){ElMessage.warning(`当前环境每镜头支持 1–${maxClipSeconds.value} 秒,请调整后再保存`);return;}local.spec=replaceWorkflowShots(local.spec,local.spec.shots.map((shot,i)=>i===index?{...shot,duration_frames:frames}:shot))}
|
||||
function selectAudio(asset:Asset){local.spec.render.audio={asset_id:asset.id,source_start_ms:0,source_end_ms:Math.max(1,Math.round((asset.duration_seconds??totalSeconds.value)*1000)),offset_frame:0,short_policy:'silence'}}
|
||||
async function confirmImport(){if(!local.draftId&&local.name==='多镜头故事'&&JSON.stringify(local.spec)===JSON.stringify(emptyWorkflow()))return true;try{await ElMessageBox.confirm('载入内容将替换当前编辑区,尚未保存的修改会丢失;服务器上已保存的草稿仍保留。是否继续?','载入工作流',{confirmButtonText:'载入为新草稿',cancelButtonText:'保留当前内容',type:'warning'});return true}catch{return false}}
|
||||
async function applyImport(spec:WorkflowSpec,name:string,session:number){if(session!==store.sessionId())return;validateWorkflow(spec,maxShots.value);if(!await confirmImport()||session!==store.sessionId())return;synchronizing=true;try{local.name=name.slice(0,255);local.spec=JSON.parse(JSON.stringify(spec));local.draftId='';local.version=0;reuse.value=''}finally{synchronizing=false}ElMessage.success(`已载入 ${spec.shots.length} 个镜头,尚未保存或运行`)}
|
||||
async function applyImport(spec:WorkflowSpec,name:string,session:number){if(session!==store.sessionId())return;validateWorkflow(spec,maxShots.value,maxClipFrames.value);if(!await confirmImport()||session!==store.sessionId())return;synchronizing=true;try{local.name=name.slice(0,255);local.spec=JSON.parse(JSON.stringify(spec));local.draftId='';local.version=0;reuse.value=''}finally{synchronizing=false}ElMessage.success(`已载入 ${spec.shots.length} 个镜头,尚未保存或运行`)}
|
||||
async function importFile(event:Event){const input=event.target as HTMLInputElement,file=input.files?.[0];if(!file||busy.value)return;busy.value=true;const session=store.sessionId();try{if(file.size>32*1024*1024)throw new Error('工作流 JSON 文件不能超过 32 MiB');await applyImport(JSON.parse(await file.text()),file.name.replace(/\.json$/i,''),session)}catch(e){if(session===store.sessionId())ElMessage.error(errorMessage(e))}finally{input.value='';busy.value=false}}
|
||||
async function loadExample(){if(busy.value)return;busy.value=true;const session=store.sessionId();try{const response=await fetch('/examples/kunpeng-storyboard.json');if(!response.ok)throw new Error('示例暂不可用,请稍后重试');await applyImport(await response.json(),'鲲鹏·北冥南徙(20镜头)',session)}catch(e){if(session===store.sessionId())ElMessage.error(errorMessage(e))}finally{busy.value=false}}
|
||||
function exportJSON(){const url=URL.createObjectURL(new Blob([JSON.stringify(local.spec,null,2)],{type:'application/json;charset=utf-8'})),link=document.createElement('a');link.href=url;link.download=`${local.name.replace(/[\\/:*?"<>|]/g,'_')||'workflow'}.json`;link.click();setTimeout(()=>URL.revokeObjectURL(url),1000)}
|
||||
@ -46,11 +49,11 @@ onMounted(()=>store.refresh().catch(e=>ElMessage.error(errorMessage(e))))
|
||||
<header class="page-heading split-heading"><div><span class="eyebrow">MANY SHOTS · ONE STORY</span><h1>把每个瞬间,连成一个故事。</h1><p>自由增减镜头,总时长随分镜变化。交互创作全天等待空闲算力。</p></div><div class="v2-actions"><el-button :disabled="busy" @click="fresh">新建</el-button><el-button :loading="busy" @click="act()">保存草稿</el-button><el-button type="primary" :loading="busy" @click="act(true)">保存并运行</el-button></div></header>
|
||||
<div class="v2-toolbar"><el-select :model-value="local.draftId" :disabled="busy" clearable placeholder="打开已保存工作流" @change="load"><el-option v-for="d in drafts" :key="d.id" :value="d.id" :label="`${d.name} · r${d.revision}`"/></el-select><el-input v-model="local.name" maxlength="255" placeholder="故事名称"/><small v-if="draft">修订 {{ draft.revision }} · 版本 {{ local.version }}<template v-if="draft.version!==local.version"> · 服务端已更新</template></small><el-button v-if="draft" text :disabled="busy" @click="load(draft.id)">重新载入</el-button><DeleteRecordButton v-if="draft" kind="draft" :record="draft" @deleted="fresh" /></div>
|
||||
<div class="v2-toolbar"><a class="el-button" href="/help/manual.html" target="_blank" rel="noopener">操作手册</a><a class="el-button" href="/help/kunpeng.html" target="_blank" rel="noopener">鲲鹏制作步骤</a><el-button :disabled="busy" @click="loadExample">载入鲲鹏示例</el-button><el-button :disabled="busy" @click="fileInput?.click()">导入工作流 JSON</el-button><el-button :disabled="busy" @click="exportJSON">导出工作流 JSON</el-button><input ref="fileInput" type="file" accept="application/json,.json" hidden @change="importFile"/><span class="muted">导入只更新本地编辑区,保存后才写入服务器,运行后才调用模型。</span></div>
|
||||
<section class="surface v2-panel"><div class="v2-toolbar"><strong>{{ local.spec.shots.length }} 个镜头 · {{ totalFrames }} 帧 · {{ totalSeconds.toFixed(2) }} 秒</strong><el-button :disabled="busy||local.spec.shots.length>=maxShots" @click="addShot">添加镜头</el-button><small class="muted">本环境最多 {{ maxShots }} 个镜头,可由管理员配置。</small></div><p class="muted">每镜头生成约 5 秒源片段,再选用其中 1–5 秒;缩短成片片段不会等比例缩短模型推理。镜头顺序或时长调整后,请复核音轨及字幕的绝对时间。</p></section>
|
||||
<div class="v2-shots"><section v-for="(shot,index) in local.spec.shots" :key="shot.key" class="surface v2-panel"><span class="eyebrow">SHOT {{ index+1 }} · {{ shotRanges[index]?.start }}–{{ shotRanges[index]?.end }} FRAMES</span><h2>镜头 {{ index+1 }}</h2><div class="v2-actions"><el-button :disabled="busy||index===0" @click="moveShot(index,index-1)">前移</el-button><el-button :disabled="busy||index===local.spec.shots.length-1" @click="moveShot(index,index+1)">后移</el-button><el-button text type="danger" :disabled="busy||local.spec.shots.length===1" @click="removeShot(index)">删除镜头</el-button></div><el-input v-model="shot.prompt" type="textarea" :rows="7" maxlength="8000" show-word-limit placeholder="描述这个镜头的画面、动作和光线"/><label>选用时长(秒)<el-input-number :model-value="(shot.duration_frames??120)/24" :min="1" :max="5" :step="0.25" :precision="2" @change="setDuration(index,$event)"/></label><small class="muted">{{ shot.duration_frames??120 }} 帧 · 24 fps</small><label>种子<el-input-number v-model="shot.parameters.seed" :min="0" :max="4294967295" :precision="0"/></label><div class="v2-actions"><el-button @click="pickShot=index;picker=true">选择参考图片</el-button><el-button v-if="shot.image_asset_id" text @click="shot.image_asset_id=null">移除参考图</el-button></div><small class="muted">{{ shot.image_asset_id||'使用文生视频' }}</small></section></div>
|
||||
<section class="surface v2-panel"><div class="v2-toolbar"><strong>{{ local.spec.shots.length }} 个镜头 · {{ totalFrames }} 帧 · {{ totalSeconds.toFixed(2) }} 秒</strong><el-button :disabled="busy||local.spec.shots.length>=maxShots" @click="addShot">添加镜头</el-button><small class="muted">本环境最多 {{ maxShots }} 个镜头,可由管理员配置。</small></div><p class="muted">每镜头可选用 1–{{ maxClipSeconds }} 秒;选用不超过 5 秒时生成约 5 秒源片段,较长镜头按各自时长原生生成。缩短选用片段不会等比例缩短模型推理;镜头顺序或时长调整后,请复核音轨及字幕的绝对时间。</p></section>
|
||||
<div class="v2-shots"><section v-for="(shot,index) in local.spec.shots" :key="shot.key" class="surface v2-panel"><span class="eyebrow">SHOT {{ index+1 }} · {{ shotRanges[index]?.start }}–{{ shotRanges[index]?.end }} FRAMES</span><h2>镜头 {{ index+1 }}</h2><div class="v2-actions"><el-button :disabled="busy||index===0" @click="moveShot(index,index-1)">前移</el-button><el-button :disabled="busy||index===local.spec.shots.length-1" @click="moveShot(index,index+1)">后移</el-button><el-button text type="danger" :disabled="busy||local.spec.shots.length===1" @click="removeShot(index)">删除镜头</el-button></div><el-input v-model="shot.prompt" type="textarea" :rows="7" maxlength="8000" show-word-limit placeholder="描述这个镜头的画面、动作和光线"/><label>选用时长(秒)<el-input-number :model-value="(shot.duration_frames??120)/24" :min="1" :max="Math.max(maxClipSeconds,(shot.duration_frames??120)/24)" :step="0.25" :precision="2" @change="setDuration(index,$event)"/></label><small class="muted">{{ shot.duration_frames??120 }} 帧 · 24 fps</small><p v-if="(shot.duration_frames??120)>maxClipFrames" class="notice warning">已恢复的镜头超出当前环境 {{ maxClipSeconds }} 秒上限,原内容已保留,请调整后再保存或运行。</p><label>种子<el-input-number v-model="shot.parameters.seed" :min="0" :max="4294967295" :precision="0"/></label><div class="v2-actions"><el-button @click="pickShot=index;picker=true">选择参考图片</el-button><el-button v-if="shot.image_asset_id" text @click="shot.image_asset_id=null">移除参考图</el-button></div><small class="muted">{{ shot.image_asset_id||'使用文生视频' }}</small></section></div>
|
||||
<section class="surface v2-panel"><h2>成片设置</h2><div class="v2-toolbar"><label>画幅<el-select v-model="local.spec.profile"><el-option value="landscape_1080_v1" label="横屏 1920 × 1080"/><el-option value="portrait_1080_v1" label="竖屏 1080 × 1920"/></el-select></label><label>适配<el-select v-model="local.spec.render.fit"><el-option value="contain" label="完整画面(留边)"/><el-option value="cover" label="填满画面(裁切)"/></el-select></label><span class="muted">24 fps · {{ totalFrames }} 帧 · {{ totalSeconds.toFixed(2) }} 秒</span></div>
|
||||
<h3>音轨</h3><el-button @click="audioPicker=true">选择音频素材</el-button><template v-if="local.spec.render.audio"><el-button text @click="local.spec.render.audio=null">移除音轨</el-button><p class="muted">{{ local.spec.render.audio.asset_id }}</p><div class="v2-toolbar"><label>源入点 ms<el-input-number v-model="local.spec.render.audio.source_start_ms" :min="0" :max="86400000" :precision="0"/></label><label>源出点 ms<el-input-number v-model="local.spec.render.audio.source_end_ms" :min="1" :max="86400000" :precision="0"/></label><label>偏移帧<el-input-number v-model="local.spec.render.audio.offset_frame" :min="0" :max="totalFrames-1" :precision="0"/></label></div><p class="muted">短音频补静音。音频选段与偏移总计不可超过 {{ totalFrames }} 帧;默认选择完整音频,不会静默截断长旁白。若超过成片时长,请增加镜头或明确修改源出点后再保存。</p><p v-if="audioOverflow" class="notice warning">音频选段超过当前成片时长,请增加镜头或调整选段后再保存。</p></template>
|
||||
<h3>人工字幕(帧)</h3><p class="muted">1 秒 = 24 帧。字幕按整片绝对时间填写,不会随镜头移动自动对齐。</p><div v-for="(row,index) in local.spec.render.subtitles" :key="index" class="v2-toolbar"><el-input-number v-model="row.start_frame" :min="0" :max="totalFrames-1" :precision="0" aria-label="字幕开始帧"/><span>至</span><el-input-number v-model="row.end_frame" :min="1" :max="totalFrames" :precision="0" aria-label="字幕结束帧"/><el-input v-model="row.text" maxlength="2000" placeholder="字幕文字"/><el-button text @click="local.spec.render.subtitles.splice(index,1)">删除</el-button></div><el-button :disabled="local.spec.render.subtitles.length>=1000" @click="local.spec.render.subtitles.push({start_frame:0,end_frame:Math.min(120,totalFrames),text:''})">添加字幕</el-button></section>
|
||||
<h3>音轨</h3><el-button @click="audioPicker=true">选择音频素材</el-button><template v-if="local.spec.render.audio"><el-button text @click="local.spec.render.audio=null">移除音轨</el-button><p class="muted">{{ local.spec.render.audio.asset_id }}</p><div class="v2-toolbar"><label>源入点 ms<el-input-number v-model="local.spec.render.audio.source_start_ms" :min="Math.min(0,local.spec.render.audio.source_start_ms)" :max="Math.max(86400000,local.spec.render.audio.source_start_ms)" :precision="0"/></label><label>源出点 ms<el-input-number v-model="local.spec.render.audio.source_end_ms" :min="Math.min(1,local.spec.render.audio.source_end_ms)" :max="Math.max(86400000,local.spec.render.audio.source_end_ms)" :precision="0"/></label><label>偏移帧<el-input-number v-model="local.spec.render.audio.offset_frame" :min="Math.min(0,local.spec.render.audio.offset_frame)" :max="Math.max(totalFrames-1,local.spec.render.audio.offset_frame)" :precision="0"/></label></div><p class="muted">短音频补静音。音频选段与偏移总计不可超过 {{ totalFrames }} 帧;默认选择完整音频,不会静默截断长旁白。若超过成片时长,请增加镜头或明确修改源出点后再保存。</p><p v-if="audioInvalid" class="notice warning">音频时间设置无效,原值已保留,请调整后再保存或运行。</p><p v-if="audioOverflow" class="notice warning">音频选段超过当前成片时长,请增加镜头或调整选段后再保存。</p></template>
|
||||
<h3>人工字幕(帧)</h3><p v-if="subtitleInvalid" class="notice warning">字幕超出当前成片或帧区间无效,原时间已保留,请调整后再保存或运行。</p><p class="muted">1 秒 = 24 帧。字幕按整片绝对时间填写,不会随镜头移动自动对齐。</p><div v-for="(row,index) in local.spec.render.subtitles" :key="index" class="v2-toolbar"><el-input-number v-model="row.start_frame" :min="Math.min(0,row.start_frame)" :max="Math.max(totalFrames-1,row.start_frame)" :precision="0" aria-label="字幕开始帧"/><span>至</span><el-input-number v-model="row.end_frame" :min="Math.min(1,row.end_frame)" :max="Math.max(totalFrames,row.end_frame)" :precision="0" aria-label="字幕结束帧"/><el-input v-model="row.text" maxlength="2000" placeholder="字幕文字"/><el-button text @click="local.spec.render.subtitles.splice(index,1)">删除</el-button></div><el-button :disabled="local.spec.render.subtitles.length>=1000" @click="local.spec.render.subtitles.push({start_frame:0,end_frame:Math.min(120,totalFrames),text:''})">添加字幕</el-button></section>
|
||||
<div v-if="runs.length" class="v2-toolbar"><h2>运行记录</h2><el-select v-model="reuse" clearable placeholder="下次运行复用已完成镜头(可选)"><el-option v-for="s in runs" :key="s.run.id" :value="s.run.id" :label="`r${s.run.draft_revision} · ${s.run.id.slice(0,8)}`"/></el-select><small class="muted">仅复用输入完全一致且产物仍存在的成功镜头。</small></div><RunCard v-for="snapshot in runs" :key="snapshot.run.id" :snapshot="snapshot"/>
|
||||
<AssetPicker v-model="picker" :kinds="['image']" @select="asset=>{const shot=local.spec.shots[pickShot];if(shot)shot.image_asset_id=asset.id}"/><AssetPicker v-model="audioPicker" :kinds="['audio']" @select="selectAudio"/>
|
||||
</div></template>
|
||||
|
||||
@ -119,9 +119,9 @@ def validate_request(payload: Any, *, workspace: Path = WORKSPACE) -> dict[str,
|
||||
normalized.update(num_frames=params.get("num_frames", 121), fps=params.get("fps", 24),
|
||||
upscale=params.get("upscale", True), upscale_width=params.get("upscale_width", 1920),
|
||||
upscale_height=params.get("upscale_height", 1080), tile_size=params.get("tile_size", 128))
|
||||
_integer(normalized["num_frames"], "num_frames", 5, 121)
|
||||
_integer(normalized["num_frames"], "num_frames", 5, 361)
|
||||
if normalized["num_frames"] % 4 != 1:
|
||||
raise ValueError("Wan num_frames must be 4n+1; long clips require a separate workflow")
|
||||
raise ValueError("Wan num_frames must be 4n+1 (up to 361 frames, about 15 seconds at 24fps)")
|
||||
if type(normalized["fps"]) is not int or normalized["fps"] != 24:
|
||||
raise ValueError("This Wan checkpoint is served at 24fps")
|
||||
if type(normalized["upscale"]) is not bool:
|
||||
|
||||
@ -57,7 +57,8 @@ class RunnerContractTests(unittest.TestCase):
|
||||
|
||||
def test_rejects_unbounded_or_incompatible_workloads(self):
|
||||
for task, params in [("video.generate", {"num_frames": 360}),
|
||||
("video.generate", {"num_frames": 361}),
|
||||
("video.generate", {"num_frames": 362}),
|
||||
("video.generate", {"num_frames": 365}),
|
||||
("video.generate", {"width": 513}),
|
||||
("image.generate", {"num_inference_steps": True}),
|
||||
("image.generate", {"width": 100000}),
|
||||
@ -65,6 +66,22 @@ class RunnerContractTests(unittest.TestCase):
|
||||
with self.subTest(params=params), self.assertRaises(ValueError):
|
||||
runner.validate_request(self.request(task, **params), workspace=self.root)
|
||||
|
||||
def test_accepts_native_ten_and_fifteen_second_clips_with_optional_enhancement(self):
|
||||
for frames in (241, 361):
|
||||
for upscale in (False, True):
|
||||
with self.subTest(frames=frames, upscale=upscale):
|
||||
request = runner.validate_request(self.request(
|
||||
"video.generate", num_frames=frames, upscale=upscale), workspace=self.root)
|
||||
self.assertEqual(request["parameters"]["num_frames"], frames)
|
||||
self.assertEqual(request["parameters"]["fps"], 24)
|
||||
self.assertEqual(runner.stage_plan(request), ["model", "upscale"] if upscale else ["model"])
|
||||
|
||||
def test_native_long_clip_still_requires_wan_frame_layout_and_twenty_four_fps(self):
|
||||
with self.assertRaisesRegex(ValueError, "4n\\+1"):
|
||||
runner.validate_request(self.request("video.generate", num_frames=360), workspace=self.root)
|
||||
with self.assertRaisesRegex(ValueError, "24fps"):
|
||||
runner.validate_request(self.request("video.generate", num_frames=361, fps=25), workspace=self.root)
|
||||
|
||||
def test_budget_admission_reserves_headroom(self):
|
||||
with patch.dict("os.environ", {"LLM_GPU_BUDGET_GIB": "68", "LLM_GPU_RESERVE_GIB": "8"}):
|
||||
self.assertAlmostEqual(adapters.memory_fraction(80 * 2**30), 0.85)
|
||||
|
||||
132
qa/shot15-browser.json
Normal file
@ -0,0 +1,132 @@
|
||||
{
|
||||
"run": "qa-shot15-browser-1794376576004-5844a9",
|
||||
"base": "http://127.0.0.1:5173",
|
||||
"api": "http://127.0.0.1:8000",
|
||||
"status": "passed",
|
||||
"checks": [
|
||||
{
|
||||
"name": "local-login-capabilities-and-sse",
|
||||
"ok": true,
|
||||
"ms": 2317,
|
||||
"frameLimit": {
|
||||
"min": 5,
|
||||
"max": 361,
|
||||
"step": 4
|
||||
},
|
||||
"workflowLimits": {
|
||||
"max_shots": 120,
|
||||
"source_frames": 121,
|
||||
"default_source_frames": 121,
|
||||
"max_source_frames": 361,
|
||||
"default_clip_frames": 120,
|
||||
"max_clip_frames": 360,
|
||||
"fps": 24
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "direct1-5-10-15-native-controls-and-intercepted-payloads",
|
||||
"ok": true,
|
||||
"ms": 5733,
|
||||
"checkedFrames": [
|
||||
25,
|
||||
121,
|
||||
241,
|
||||
361
|
||||
],
|
||||
"forwardedJobPosts": 0
|
||||
},
|
||||
{
|
||||
"name": "direct-over15-local-draft-refused-without-forwarding",
|
||||
"ok": true,
|
||||
"ms": 3147
|
||||
},
|
||||
{
|
||||
"name": "workflow-default5-and-mixed30second-fixture-save",
|
||||
"ok": true,
|
||||
"ms": 1485,
|
||||
"defaultShotSeconds": 5,
|
||||
"savedShotFrames": [
|
||||
120,
|
||||
240,
|
||||
360
|
||||
],
|
||||
"savedTotalFrames": 720
|
||||
},
|
||||
{
|
||||
"name": "workflow-fixture-reload-export-and-import",
|
||||
"ok": true,
|
||||
"ms": 1679,
|
||||
"reloadedFrames": 720,
|
||||
"exportedFrames": 720,
|
||||
"importedFrames": 720
|
||||
},
|
||||
{
|
||||
"name": "workflow-json-over15-rejected-without-changing-timeline",
|
||||
"ok": true,
|
||||
"ms": 119
|
||||
},
|
||||
{
|
||||
"name": "local-vite-help-layout",
|
||||
"ok": true,
|
||||
"ms": 345
|
||||
},
|
||||
{
|
||||
"name": "final-sse-and-no-browser-errors",
|
||||
"ok": true,
|
||||
"ms": 10,
|
||||
"pageErrors": 0,
|
||||
"serverErrors": 0,
|
||||
"liveStreams": 1
|
||||
}
|
||||
],
|
||||
"screenshots": [
|
||||
"shot15-direct15-361frames.png",
|
||||
"shot15-direct15-selected.png",
|
||||
"shot15-direct-over15-refused.png",
|
||||
"shot15-workflow30-timeline.png",
|
||||
"shot15-workflow-json-import30.png",
|
||||
"shot15-workflow-over15-refused.png",
|
||||
"shot15-help-desktop.png"
|
||||
],
|
||||
"interceptedJobs": [
|
||||
{
|
||||
"task_type": "video.generate",
|
||||
"num_frames": 25,
|
||||
"fps": 24,
|
||||
"count": 1,
|
||||
"promptIsFixture": true
|
||||
},
|
||||
{
|
||||
"task_type": "video.generate",
|
||||
"num_frames": 121,
|
||||
"fps": 24,
|
||||
"count": 1,
|
||||
"promptIsFixture": true
|
||||
},
|
||||
{
|
||||
"task_type": "video.generate",
|
||||
"num_frames": 241,
|
||||
"fps": 24,
|
||||
"count": 1,
|
||||
"promptIsFixture": true
|
||||
},
|
||||
{
|
||||
"task_type": "video.generate",
|
||||
"num_frames": 361,
|
||||
"fps": 24,
|
||||
"count": 1,
|
||||
"promptIsFixture": true
|
||||
}
|
||||
],
|
||||
"forwardedJobPosts": 0,
|
||||
"blockedWrites": [],
|
||||
"pageErrors": [],
|
||||
"serverErrors": [],
|
||||
"cleanup": [
|
||||
{
|
||||
"kind": "fixture-workflow",
|
||||
"status": 200
|
||||
}
|
||||
],
|
||||
"remainingFixtureDrafts": 0
|
||||
}
|
||||
BIN
qa/shot15-direct-over15-refused.png
Normal file
|
After Width: | Height: | Size: 276 KiB |
BIN
qa/shot15-direct15-361frames.png
Normal file
|
After Width: | Height: | Size: 284 KiB |
BIN
qa/shot15-direct15-selected.png
Normal file
|
After Width: | Height: | Size: 267 KiB |
107
qa/shot15-e2e.json
Normal file
@ -0,0 +1,107 @@
|
||||
{
|
||||
"passed": true,
|
||||
"job_id": "ee21af8ff41b458ab777538042e61590",
|
||||
"upstream_id": "b5b79b6af2bb4bacbf9a5c8ec1dc0813",
|
||||
"parameters": {
|
||||
"width": 512,
|
||||
"height": 288,
|
||||
"num_frames": 361,
|
||||
"fps": 24,
|
||||
"num_inference_steps": 4,
|
||||
"guidance_scale": 5.0,
|
||||
"seed": 42,
|
||||
"upscale": true,
|
||||
"upscale_width": 512,
|
||||
"upscale_height": 288,
|
||||
"tile_size": 128
|
||||
},
|
||||
"elapsed_seconds": 156.80338215827942,
|
||||
"outputs": [
|
||||
{
|
||||
"asset_id": "88dbbbea33db4674aac0c2385da42080",
|
||||
"path": "E:\\workspace\\hybrid\\cmvr-visual\\qa\\generated\\shot15-e2e-0.mp4",
|
||||
"probe": {
|
||||
"programs": [],
|
||||
"stream_groups": [],
|
||||
"streams": [
|
||||
{
|
||||
"width": 512,
|
||||
"height": 288,
|
||||
"avg_frame_rate": "24/1",
|
||||
"duration": "15.041667",
|
||||
"nb_read_frames": "361"
|
||||
}
|
||||
],
|
||||
"format": {
|
||||
"duration": "15.041667",
|
||||
"size": "583653"
|
||||
}
|
||||
},
|
||||
"full_decode": "passed"
|
||||
},
|
||||
{
|
||||
"asset_id": "398a29c40f2347fab8d0295185794dd2",
|
||||
"path": "E:\\workspace\\hybrid\\cmvr-visual\\qa\\generated\\shot15-e2e-1.mp4",
|
||||
"probe": {
|
||||
"programs": [],
|
||||
"stream_groups": [],
|
||||
"streams": [
|
||||
{
|
||||
"width": 512,
|
||||
"height": 288,
|
||||
"avg_frame_rate": "24/1",
|
||||
"duration": "15.041667",
|
||||
"nb_read_frames": "361"
|
||||
}
|
||||
],
|
||||
"format": {
|
||||
"duration": "15.041667",
|
||||
"size": "4979416"
|
||||
}
|
||||
},
|
||||
"full_decode": "passed"
|
||||
}
|
||||
],
|
||||
"model_stages": [
|
||||
{
|
||||
"model": "[server file]",
|
||||
"stage": "generation",
|
||||
"engine": "vllm-omni",
|
||||
"parameters": {
|
||||
"fps": 24,
|
||||
"seed": 42,
|
||||
"width": 512,
|
||||
"height": 288,
|
||||
"upscale": true,
|
||||
"tile_size": 128,
|
||||
"num_frames": 361,
|
||||
"upscale_width": 512,
|
||||
"guidance_scale": 5.0,
|
||||
"upscale_height": 288,
|
||||
"num_inference_steps": 4
|
||||
},
|
||||
"cpu_offload": {
|
||||
"mode": "module",
|
||||
"components": [
|
||||
"dit",
|
||||
"text_encoder"
|
||||
],
|
||||
"pin_memory": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"fit": "aspect-preserving letterbox",
|
||||
"model": "[server file]",
|
||||
"stage": "realesrgan",
|
||||
"engine": "pytorch",
|
||||
"frames": 361,
|
||||
"tile_pad": 10,
|
||||
"tile_size": 128,
|
||||
"resolution": [
|
||||
512,
|
||||
288
|
||||
]
|
||||
}
|
||||
],
|
||||
"scope": "low-step 512x288 real vllm-omni generation plus Real-ESRGAN; not a new high-quality 1080p benchmark"
|
||||
}
|
||||
BIN
qa/shot15-help-desktop.png
Normal file
|
After Width: | Height: | Size: 119 KiB |
62
qa/shot15-timeline-browser.json
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"run": "qa-shot15-browser-1794376873314-399f26",
|
||||
"base": "http://127.0.0.1:5173",
|
||||
"api": "http://127.0.0.1:8000",
|
||||
"status": "passed",
|
||||
"checks": [
|
||||
{
|
||||
"name": "local-login-capabilities-and-sse",
|
||||
"ok": true,
|
||||
"ms": 2131,
|
||||
"frameLimit": {
|
||||
"min": 5,
|
||||
"max": 361,
|
||||
"step": 4
|
||||
},
|
||||
"workflowLimits": {
|
||||
"max_shots": 120,
|
||||
"source_frames": 121,
|
||||
"default_source_frames": 121,
|
||||
"max_source_frames": 361,
|
||||
"default_clip_frames": 120,
|
||||
"max_clip_frames": 360,
|
||||
"fps": 24
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "timeline15-to5-retains-subtitle-and-audio-after-remount",
|
||||
"ok": true,
|
||||
"ms": 4790,
|
||||
"subtitleFrames": [
|
||||
240,
|
||||
360
|
||||
],
|
||||
"audioOffsetFrame": 300,
|
||||
"totalFrames": 120,
|
||||
"invalidSaveAndRunBlockedBeforeHTTP": true
|
||||
},
|
||||
{
|
||||
"name": "timeline-repairs-require-explicit-user-edits",
|
||||
"ok": true,
|
||||
"ms": 299,
|
||||
"explicitlyRepairedSubtitleFrames": [
|
||||
0,
|
||||
120
|
||||
],
|
||||
"explicitlyRepairedAudioOffset": 0,
|
||||
"serverDraftsCreated": 0,
|
||||
"pageErrors": 0
|
||||
}
|
||||
],
|
||||
"screenshots": [
|
||||
"shot15-timeline-restored-out-of-range.png",
|
||||
"shot15-timeline-explicitly-repaired.png"
|
||||
],
|
||||
"interceptedJobs": [],
|
||||
"forwardedJobPosts": 0,
|
||||
"blockedWrites": [],
|
||||
"pageErrors": [],
|
||||
"serverErrors": [],
|
||||
"cleanup": [],
|
||||
"remainingFixtureDrafts": 0
|
||||
}
|
||||
BIN
qa/shot15-timeline-explicitly-repaired.png
Normal file
|
After Width: | Height: | Size: 152 KiB |
35
qa/shot15-timeline-repaired.json
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"schema_version": 2,
|
||||
"shots": [
|
||||
{
|
||||
"key": "shot_1",
|
||||
"prompt": "qa-shot15-browser-1794376873314-399f26",
|
||||
"image_asset_id": null,
|
||||
"parameters": {
|
||||
"seed": 42
|
||||
},
|
||||
"duration_frames": 120
|
||||
}
|
||||
],
|
||||
"profile": "landscape_1080_v1",
|
||||
"render": {
|
||||
"fps": 24,
|
||||
"total_frames": 120,
|
||||
"fit": "contain",
|
||||
"audio": {
|
||||
"asset_id": "qa-shot15-browser-1794376873314-399f26-local-audio",
|
||||
"source_start_ms": 0,
|
||||
"source_end_ms": 1000,
|
||||
"offset_frame": 0,
|
||||
"short_policy": "silence"
|
||||
},
|
||||
"subtitles": [
|
||||
{
|
||||
"start_frame": 0,
|
||||
"end_frame": 120,
|
||||
"text": "retained ending"
|
||||
}
|
||||
],
|
||||
"template_version": "plain-v1"
|
||||
}
|
||||
}
|
||||
BIN
qa/shot15-timeline-restored-out-of-range.png
Normal file
|
After Width: | Height: | Size: 135 KiB |
38
qa/shot15-validation.json
Normal file
@ -0,0 +1,38 @@
|
||||
{
|
||||
"tests": {
|
||||
"backend_linux": 309,
|
||||
"backend_subtests": 20,
|
||||
"media_linux": 7,
|
||||
"runner_linux": 20,
|
||||
"runner_subtests": 24,
|
||||
"frontend": 124,
|
||||
"browser": 8,
|
||||
"timeline_browser": 3
|
||||
},
|
||||
"isolation": {
|
||||
"llmuser-workspace": {
|
||||
"same_id": true,
|
||||
"same_start": true
|
||||
},
|
||||
"llmuser-gpu-guard": {
|
||||
"same_id": true,
|
||||
"same_start": true
|
||||
},
|
||||
"cmvr-qwen38-fast": {
|
||||
"same_id": true,
|
||||
"same_start": true
|
||||
},
|
||||
"cmvr-qwen38-accurate": {
|
||||
"same_id": true,
|
||||
"same_start": true
|
||||
},
|
||||
"cmvr-visual-tts": {
|
||||
"same_id": true,
|
||||
"same_start": true
|
||||
}
|
||||
},
|
||||
"runner_sha256": "37d13052d39b568298dc59027de3ba6b4788aaf4dc4124c42163d8bb54ca498d",
|
||||
"model_service_identity_unchanged": true,
|
||||
"business_database_migration": false,
|
||||
"runtime": "local Windows API/Vite with remote GPU model service"
|
||||
}
|
||||
BIN
qa/shot15-workflow-json-import30.png
Normal file
|
After Width: | Height: | Size: 209 KiB |
41
qa/shot15-workflow-mixed.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"schema_version": 2,
|
||||
"shots": [
|
||||
{
|
||||
"key": "shot_1",
|
||||
"prompt": "qa-shot15-browser-1794376576004-5844a9 shot 1",
|
||||
"duration_frames": 120,
|
||||
"image_asset_id": null,
|
||||
"parameters": {
|
||||
"seed": 42
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "shot_2",
|
||||
"prompt": "qa-shot15-browser-1794376576004-5844a9 shot 2",
|
||||
"duration_frames": 240,
|
||||
"image_asset_id": null,
|
||||
"parameters": {
|
||||
"seed": 42
|
||||
}
|
||||
},
|
||||
{
|
||||
"key": "shot_3",
|
||||
"prompt": "qa-shot15-browser-1794376576004-5844a9 shot 3",
|
||||
"duration_frames": 360,
|
||||
"image_asset_id": null,
|
||||
"parameters": {
|
||||
"seed": 42
|
||||
}
|
||||
}
|
||||
],
|
||||
"profile": "landscape_1080_v1",
|
||||
"render": {
|
||||
"fps": 24,
|
||||
"total_frames": 720,
|
||||
"fit": "contain",
|
||||
"audio": null,
|
||||
"subtitles": [],
|
||||
"template_version": "plain-v1"
|
||||
}
|
||||
}
|
||||
BIN
qa/shot15-workflow-over15-refused.png
Normal file
|
After Width: | Height: | Size: 218 KiB |
BIN
qa/shot15-workflow30-timeline.png
Normal file
|
After Width: | Height: | Size: 206 KiB |