feat(generator): 카메라 모션을 media.py 로 통합하고 스토리보드가 컷별로 선택하도록 확장
This commit is contained in:
1 parent
434d0ca9c0
commit
e1dca36d21
31 files changed
+485
-295
No files matched your search
@@ -203,6 +203,17 @@ SB_SYSTEM = """\
|
||||
(예: eyes squeezed shut while laughing, sleepy half-closed eyes, a playful wink,
|
||||
teary closed eyes). 평범한 장면은 굳이 눈을 적지 말고 뜬 눈(기본)으로 두면 된다.
|
||||
→ 그래야 컷마다 눈 표정이 다양해진다.
|
||||
- camera: 그 장면에 어울리는 카메라 움직임을 아래 중 하나로 고른다. 장면의 '감정'에 맞춰라.
|
||||
reveal : 상황 전체가 드러남 (첫 컷 기본)
|
||||
punch_in : 반전·폭로·핵심 한 방 (강하다. 영상당 1~2번만)
|
||||
slow_in : 몰입이 쌓이는 서술, 마지막 CTA
|
||||
slow_out : 상황이 점점 보이는 서술
|
||||
pan_left / pan_right : 이동·전개·시간 흐름
|
||||
tilt_up : 올려다봄 — 권위·거대함·감탄
|
||||
tilt_down : 내려다봄 — 추락·좌절·한심함
|
||||
shake : 충격·당황·사고 (강하다. 영상당 1번이면 충분)
|
||||
hold : 정적인 대사·여운. 강한 컷 앞뒤에 넣으면 대비가 산다
|
||||
★ 같은 값을 3연속으로 쓰지 마라. 강한 효과(punch_in/shake)를 연달아 쓰면 산만해진다.
|
||||
|
||||
[전역 설정]
|
||||
- character_sheet: 이 영상에 일관되게 등장할 주인공 캐릭터를 영어로 정의. 한국사 인물을 '귀여운 통통한 고양이'로 의인화.
|
||||
@@ -238,8 +249,18 @@ SB_SCHEMA = {
|
||||
"narration": {"type": "string"},
|
||||
"caption": {"type": "string"},
|
||||
"image_prompt": {"type": "string"},
|
||||
# 값은 media.CAMERA_KINDS 와 반드시 일치해야 한다.
|
||||
# 모르는 값이 오면 렌더가 조용히 기본 순환으로 떨어진다.
|
||||
"camera": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"reveal", "punch_in", "slow_in", "slow_out",
|
||||
"pan_left", "pan_right", "tilt_up", "tilt_down",
|
||||
"shake", "hold",
|
||||
],
|
||||
},
|
||||
},
|
||||
"required": ["narration", "caption", "image_prompt"],
|
||||
"required": ["narration", "caption", "image_prompt", "camera"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -575,30 +575,6 @@ _wrap_lines = MU._wrap_lines
|
||||
mix_bgm = MU.mix_bgm
|
||||
|
||||
|
||||
def _scene_motion(idx: int, n: int, frames: int) -> str:
|
||||
"""장면별 zoompan 카메라 모션(z/x/y 표현식만 반환 — d/s/fps 는 호출부에서 붙임).
|
||||
- 1번 컷(훅): 펀치인 — 1.30 에서 확 들어와 시선 고정 후 서서히 줌
|
||||
- 뒤에서 3번째 컷(피벗 추정 — 억지 광고 전환): 셰이크. 장면 역할 태그가
|
||||
스토리보드에 없어 위치 휴리스틱(hook→story→pivot→cta 순서상 cta 직전)
|
||||
- 나머지: 줌인 / 줌아웃 / 좌→우 팬 / 우→좌 팬 순환
|
||||
"""
|
||||
center = "x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)'"
|
||||
f = max(frames, 1)
|
||||
if idx == 1: # 훅: 리빌(살짝 당김→전체)
|
||||
return f"zoompan=z='max(1.10-0.10*on/{f},1.0)':{center}"
|
||||
if n >= 6 and idx == n - 2: # 피벗: 아주 약한 흔들림(줌 1.06 유지)
|
||||
return ("zoompan=z='1.06':"
|
||||
"x='iw/2-(iw/zoom/2)+8*sin(on*1.6)':"
|
||||
"y='ih/2-(ih/zoom/2)+6*cos(on*2.2)'")
|
||||
kind = idx % 4
|
||||
if kind == 0: # 줌아웃(끝에 전체)
|
||||
return f"zoompan=z='max(1.10-0.10*on/{f},1.0)':{center}"
|
||||
if kind == 1: # 줌인(시작에 전체)
|
||||
return f"zoompan=z='min(1.0+0.10*on/{f},1.10)':{center}"
|
||||
if kind == 2: # 약한 좌→우 팬(줌 1.06, ~6%만 이동)
|
||||
return f"zoompan=z='1.06':x='(iw-iw/zoom)*on/{f}':y='ih/2-(ih/zoom/2)'"
|
||||
return f"zoompan=z='1.06':x='(iw-iw/zoom)*(1-on/{f})':y='ih/2-(ih/zoom/2)'"
|
||||
|
||||
|
||||
def build_video(scenes, audio_paths, img_paths, out_path, link=None, link_seconds=3.0,
|
||||
store=None, cta=None, speed=1.0, trim_silence=True, tail=0.15,
|
||||
@@ -619,6 +595,9 @@ def build_video(scenes, audio_paths, img_paths, out_path, link=None, link_second
|
||||
tmp.mkdir(exist_ok=True)
|
||||
segs = []
|
||||
total = 0.0
|
||||
# 카메라 순환 시작점 — 콘텐츠마다 다르되 같은 콘텐츠면 항상 같다.
|
||||
# (media.motion_seed 주석 참조)
|
||||
cam_seed = MU.motion_seed("".join(str(s.get("narration", "")) for s in scenes))
|
||||
|
||||
for idx, (sc, ap, ip) in enumerate(zip(scenes, audio_paths, img_paths), 1):
|
||||
# 컷편집용으로 음성 가공(빠르게 + 침묵 제거) 후 그 길이를 컷 길이로 사용
|
||||
@@ -635,7 +614,7 @@ def build_video(scenes, audio_paths, img_paths, out_path, link=None, link_second
|
||||
band_h = int(H * BAND_RATIO)
|
||||
img_h = H - band_h
|
||||
bw, bh = int(W * 3), int(img_h * 3) # zoompan 정수픽셀 반올림 떨림 방지용 업스케일(2배는 떨림 재발, 3배로 메모리·화질 절충)
|
||||
motion = _scene_motion(idx, len(scenes), frames)
|
||||
motion = MU.scene_motion(sc, idx, len(scenes), frames, cam_seed)
|
||||
fd = min(0.18, dur / 4) # 컷 전환 화이트 페이드(짧은 컷은 비례 축소)
|
||||
# 페이드는 '그림'에만 → 캡션(자막)은 그 위에 나중에 얹어 항상 선명하게 유지.
|
||||
# 첫 컷(hook)은 흰 화면 없이 바로 이미지로 시작 → 페이드인은 2번째 컷부터.
|
||||
|
||||
Reference in new issue
Block a user