feat:优化架构
This commit is contained in:
43
engine/director.py
Normal file
43
engine/director.py
Normal file
@@ -0,0 +1,43 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
def _read_scene(scene: Any) -> tuple[str, str, str]:
|
||||
if hasattr(scene, "image_prompt") and hasattr(scene, "video_motion") and hasattr(scene, "narration"):
|
||||
return (
|
||||
str(getattr(scene, "image_prompt", "")).strip(),
|
||||
str(getattr(scene, "video_motion", "")).strip(),
|
||||
str(getattr(scene, "narration", "")).strip(),
|
||||
)
|
||||
if isinstance(scene, dict):
|
||||
return (
|
||||
str(scene.get("image_prompt", "")).strip(),
|
||||
str(scene.get("video_motion", scene.get("motion", ""))).strip(),
|
||||
str(scene.get("narration", scene.get("tts", ""))).strip(),
|
||||
)
|
||||
return ("", "", "")
|
||||
|
||||
|
||||
def scenes_to_shots(scenes: list) -> list[dict[str, Any]]:
|
||||
shots: list[dict[str, Any]] = []
|
||||
for scene_idx, scene in enumerate(scenes, start=1):
|
||||
image_prompt, motion, tts = _read_scene(scene)
|
||||
scene_id = f"scene_{scene_idx:02d}"
|
||||
shot_id = f"{scene_id}_01"
|
||||
# Keep default duration simple and deterministic for MVP.
|
||||
duration = 3
|
||||
shots.append(
|
||||
{
|
||||
"shot_id": shot_id,
|
||||
"scene_id": scene_id,
|
||||
"duration": int(duration),
|
||||
"image_prompt": image_prompt,
|
||||
"motion": motion,
|
||||
"camera": "",
|
||||
"tts": tts,
|
||||
"status": "pending",
|
||||
}
|
||||
)
|
||||
return shots
|
||||
|
||||
Reference in New Issue
Block a user