"""Compose a silent 12-second promo from the generated poster; no external upload.""" from pathlib import Path import shutil import subprocess root = Path(__file__).resolve().parents[1] out = root / 'public/examples' out.mkdir(exist_ok=True) font = Path('C:/Windows/Fonts/malgun.ttf') assert font.is_file() lines = ['잠깐 쉬어 가도 좋은 곳', '커피 한 잔의 여유', '모퉁이 카페 · 학습용 예시'] text_paths = [] for i, line in enumerate(lines): path = out / f'cafe-video-scene-{i + 1}.txt' path.write_text(line, encoding='utf-8') text_paths.append(path) font_arg = str(font).replace('\\', '/').replace(':', '\\:') filters = ['scale=1080:1080', "zoompan=z='min(zoom+0.00015,1.045)':x='iw/2-(iw/zoom/2)':y='ih/2-(ih/zoom/2)':d=360:s=720x720:fps=30", 'drawbox=x=0:y=620:w=720:h=100:color=0x2b2119@0.82:t=fill'] for i, path in enumerate(text_paths): filters.append(f"drawtext=fontfile='{font_arg}':textfile='{path.name}':fontsize=25:fontcolor=white:x=(w-tw)/2:y=650:enable='gte(t,{i * 4})*lt(t,{(i + 1) * 4})'") subprocess.run([shutil.which('ffmpeg'), '-y', '-loop', '1', '-i', str(root / 'public/images/examples/cafe-poster.png'), '-vf', ','.join(filters), '-t', '12', '-an', '-c:v', 'libx264', '-pix_fmt', 'yuv420p', '-crf', '22', '-movflags', '+faststart', str(out / 'cafe-promo.mp4')], cwd=out, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) print('Created cafe-promo.mp4: 720x720, 30 fps, 12 seconds, silent.')