Support per-chunk timeline durations
This commit is contained in:
+10
-3
@@ -227,9 +227,16 @@ class H3ContinuumSamplerV34(H3ContinuumSamplerProduction):
|
||||
from ..reference_video import prepare_reference_video_source
|
||||
from ..temporal import align_frame_count_up
|
||||
|
||||
target_frames = round(
|
||||
int(kwargs["chunks"]) * float(kwargs["chunk_seconds"]) * FPS
|
||||
)
|
||||
from ..v2.prompts import build_sampler_prompt_plan
|
||||
prompt_plan = build_sampler_prompt_plan(
|
||||
prompt_mode=kwargs["prompt_mode"],
|
||||
prompt_script=kwargs.get("prompt_script", ""),
|
||||
sequence_prompt=kwargs.get("sequence_prompt"),
|
||||
prompt_plan=None,
|
||||
chunks=int(kwargs["chunks"]),
|
||||
chunk_seconds=float(kwargs["chunk_seconds"]),
|
||||
)
|
||||
target_frames = round(sum(prompt_plan.get("chunk_durations") or [float(kwargs["chunk_seconds"])] * int(kwargs["chunks"])) * FPS)
|
||||
source = prepare_driving_audio_source(
|
||||
driving_audio,
|
||||
audio_vae,
|
||||
|
||||
+3
-2
@@ -197,7 +197,7 @@ def _apply_review_decode_scope(
|
||||
from ..v2.sequence import _terminal_flf_merge_enabled
|
||||
from .plan import prepare_physical_decode_entries
|
||||
|
||||
terminal_merged = sequence_complete and _terminal_flf_merge_enabled(
|
||||
terminal_merged = sequence_complete and len(set(assembly_plan.get("chunk_durations") or [float(chunk_seconds)] * int(configured_chunks))) == 1 and _terminal_flf_merge_enabled(
|
||||
multi_chunk_flf=(
|
||||
first_frame is not None
|
||||
and last_frame is not None
|
||||
@@ -643,7 +643,8 @@ class H3ContinuumSamplerV3:
|
||||
configured_chunks = int(chunks)
|
||||
completed_chunks = len(entries)
|
||||
sequence_complete = completed_chunks == configured_chunks
|
||||
terminal_merged = sequence_complete and _terminal_flf_merge_enabled(
|
||||
prompt_durations = [float(entry.get("plan", {}).get("requested_extend_seconds", chunk_seconds)) for entry in entries]
|
||||
terminal_merged = sequence_complete and len(set(prompt_durations)) == 1 and _terminal_flf_merge_enabled(
|
||||
multi_chunk_flf=(
|
||||
first_frame is not None
|
||||
and advanced_values["last_frame"] is not None
|
||||
|
||||
+27
-12
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user