Support per-chunk timeline durations
tests / test (push) Canceled after 0s
tests / windows-storage (push) Canceled after 0s

This commit is contained in:
2026-11-10 11:46:19 +00:00
parent 3716b02a57
commit 92135c0db0
13 changed files with 153 additions and 58 deletions
+27 -12
View File
@@ -19,11 +19,12 @@ class AssemblyPlanError(ValueError):
pass
def make_assembly_plan(
entries: list[dict[str, Any]],
*,
chunk_seconds: float,
preserve_final_frame: bool,
def make_assembly_plan(
entries: list[dict[str, Any]],
*,
chunk_seconds: float,
chunk_durations: list[float] | None = None,
preserve_final_frame: bool,
) -> dict[str, Any]:
if not entries:
raise AssemblyPlanError("cannot create an assembly plan for an empty sequence")
@@ -61,14 +62,18 @@ def make_assembly_plan(
}
)
result = {
durations = [float(value) for value in (chunk_durations or [chunk_seconds] * len(chunks))]
if len(durations) != len(chunks):
raise AssemblyPlanError("chunk duration count does not match chunks")
result = {
"magic": ASSEMBLY_PLAN_MAGIC,
"schema_version": ASSEMBLY_PLAN_SCHEMA_VERSION,
"fps": FPS,
"width": int(width),
"height": int(height),
"chunk_seconds": float(chunk_seconds),
"target_frames": int(round(len(chunks) * float(chunk_seconds) * FPS)),
"chunk_seconds": float(chunk_seconds),
"chunk_durations": durations,
"target_frames": int(round(sum(durations) * FPS)),
"preserve_final_frame": bool(preserve_final_frame),
"chunks": chunks,
}
@@ -89,8 +94,11 @@ def validate_assembly_plan(plan: Any) -> dict[str, Any]:
raise AssemblyPlanError("assembly plan FPS must be 24")
if int(plan.get("width", 0)) <= 0 or int(plan.get("height", 0)) <= 0:
raise AssemblyPlanError("assembly plan dimensions are invalid")
if float(plan.get("chunk_seconds", 0.0)) <= 0:
raise AssemblyPlanError("assembly plan chunk duration is invalid")
if float(plan.get("chunk_seconds", 0.0)) <= 0:
raise AssemblyPlanError("assembly plan chunk duration is invalid")
durations = plan.get("chunk_durations") or [float(plan["chunk_seconds"])] * len(plan.get("chunks") or [])
if not isinstance(durations, list) or len(durations) != len(plan.get("chunks") or []):
raise AssemblyPlanError("assembly plan chunk durations are invalid")
if int(plan.get("target_frames", 0)) <= 0:
raise AssemblyPlanError("assembly plan target frame count is invalid")
@@ -356,6 +364,7 @@ def prepare_physical_decode_entries(
entries,
*,
chunk_seconds: float,
chunk_durations: list[float] | None = None,
preserve_final_frame: bool,
terminal_merged: bool,
terminal_initial_pair: bool | None = None,
@@ -363,9 +372,15 @@ def prepare_physical_decode_entries(
"""Return external-VAE decode units while preserving logical plan metadata."""
logical_entries = list(entries)
if chunk_durations is None:
chunk_durations = [
float(entry.get("plan", {}).get("requested_extend_seconds", chunk_seconds))
for entry in logical_entries
]
plan = make_assembly_plan(
logical_entries,
chunk_seconds=float(chunk_seconds),
logical_entries,
chunk_seconds=float(chunk_seconds),
chunk_durations=chunk_durations,
preserve_final_frame=bool(preserve_final_frame),
)
logical_chunk_indices = [