44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
"""⑩ hybrid 수동 확인용 — 생성 클립 위에 원본 고정층을 덮는다.
|
|
|
|
사용: uv run python -m tests.playreel.test_hybrid_poster <goods_id> <config.json>
|
|
config는 작품별 좌표 파일이다(fixed_rects·sil_poly·glyphs·punches). 아직 사람이 쓴다.
|
|
결과는 nol_<goods_id>/hybrid.mp4 와 hybrid_proof.jpg.
|
|
"""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from models.hybrid import LayerConfig
|
|
from services.hybrid_poster import render_hybrid
|
|
|
|
TEST_RESULT_DIR = Path(__file__).parent.parent / "test_result" / "playreel"
|
|
|
|
|
|
def main() -> None:
|
|
goods_id, config_path = sys.argv[1], Path(sys.argv[2])
|
|
product_dir = TEST_RESULT_DIR / f"nol_{goods_id}"
|
|
poster_path = product_dir / "upscaled.png"
|
|
clip_path = product_dir / "clip.mp4"
|
|
for required in (poster_path, clip_path, config_path):
|
|
if not required.exists():
|
|
raise SystemExit(f"{required} 없음")
|
|
|
|
config = LayerConfig.model_validate_json(config_path.read_text(encoding="utf-8"))
|
|
print(f"config {config_path.name} · mask={config.mask.mode}"
|
|
f" · 고정사각 {len(config.fixed_rects)} · 글리프 {len(config.glyphs)}"
|
|
f" · 펀치 {len(config.punches)} · 정합 {config.hybrid.register_frames}")
|
|
|
|
result = render_hybrid(poster_path, clip_path.read_bytes(), config, preview=True)
|
|
|
|
video_path = product_dir / "hybrid.mp4"
|
|
video_path.write_bytes(result.video)
|
|
print(f"{result.frames}프레임 · {result.duration}초 · {len(result.video) / 1e6:.1f}MB")
|
|
if result.proof:
|
|
proof_path = product_dir / "hybrid_proof.jpg"
|
|
result.proof.save(proof_path, quality=85)
|
|
print(f"{proof_path}")
|
|
print(f"{video_path}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|