Refine caption styling
This commit is contained in:
parent
24f226aa75
commit
630c7a0f74
1 changed files with 16 additions and 5 deletions
21
movmaker.py
21
movmaker.py
|
|
@ -402,7 +402,7 @@ def build_video(
|
|||
stamp_font = str(Path.home() / ".local/share/fonts/google/Inter%5Bopsz,wght%5D.ttf")
|
||||
if title_lines:
|
||||
title_font_size = max(60, height // 10)
|
||||
subtitle_font_size = max(34, height // 20)
|
||||
subtitle_font_size = max(40, height // 18)
|
||||
main_title = data.title or title_lines[0]
|
||||
subtitle = " | ".join(x for x in [data.date, data.place] if x)
|
||||
title_alpha = "if(lt(t\\,5)\\,1\\,if(lt(t\\,6)\\,6-t\\,0))"
|
||||
|
|
@ -438,7 +438,7 @@ def build_video(
|
|||
filters.append(f"[{current}]copy[{title_label}]")
|
||||
|
||||
caption_label = title_label
|
||||
caption_size = max(18, height // 42)
|
||||
caption_size = subtitle_font_size if title_lines else max(40, height // 18)
|
||||
for idx, caption in enumerate(captions):
|
||||
if not caption:
|
||||
continue
|
||||
|
|
@ -456,13 +456,24 @@ def build_video(
|
|||
end = transition_offsets[idx]
|
||||
if end <= start:
|
||||
continue
|
||||
caption_fade = min(1.0, max(0.0, (end - start) / 2))
|
||||
caption_alpha = (
|
||||
f"if(lt(t\\,{start + caption_fade:.3f})\\,(t-{start:.3f})/{caption_fade:.3f}\\,"
|
||||
f"if(lt(t\\,{end - caption_fade:.3f})\\,1\\,({end:.3f}-t)/{caption_fade:.3f}))"
|
||||
) if caption_fade > 0 else "1"
|
||||
next_label = f"caption{idx}"
|
||||
filters.append(
|
||||
f"[{caption_label}]drawtext=fontfile='{stamp_font}':text='{drawtext_escape(caption)}':x=(w-text_w)/2:y=h-text_h-62:"
|
||||
f"[{caption_label}]drawtext=fontfile='{title_font}':text='{drawtext_escape(caption)}':x=(w-text_w)/2:y=h-text_h-62:"
|
||||
f"fontsize={caption_size}:fontcolor=white:borderw=1:bordercolor=black:"
|
||||
f"enable='between(t,{start:.3f},{end:.3f})'[{next_label}]"
|
||||
f"alpha='{caption_alpha}':enable='between(t,{start:.3f},{end:.3f})'[{next_label}]"
|
||||
)
|
||||
caption_label = next_label
|
||||
bold_label = f"caption{idx}b"
|
||||
filters.append(
|
||||
f"[{next_label}]drawtext=fontfile='{title_font}':text='{drawtext_escape(caption)}':x=(w-text_w)/2+1:y=h-text_h-62:"
|
||||
f"fontsize={caption_size}:fontcolor=white:borderw=1:bordercolor=black:"
|
||||
f"alpha='{caption_alpha}':enable='between(t,{start:.3f},{end:.3f})'[{bold_label}]"
|
||||
)
|
||||
caption_label = bold_label
|
||||
|
||||
stamp_size = max(14, height // 65)
|
||||
stamp_lines = [x for x in [data.title, data.date, data.place] if x]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue