From f43f6f3ef48185d173e8b75bbea78296fad7be32 Mon Sep 17 00:00:00 2001 From: hbrain Date: Sun, 31 May 2026 23:08:21 +0000 Subject: [PATCH] Embed teaser and quote_da metadata only in rendered videos --- movmaker.py | 64 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/movmaker.py b/movmaker.py index 9210f1a..76c5035 100755 --- a/movmaker.py +++ b/movmaker.py @@ -85,6 +85,8 @@ def tool_path(local_path: Path, fallback: str) -> str: @dataclass class MovieData: title: str = "" + teaser: str = "" + quote_da: str = "" date: str = "" place: str = "" description: str = "" @@ -698,6 +700,10 @@ def parse_data_file(path: Path | None) -> MovieData: continue if low in {"title", "name"}: data.title = value + elif low in {"teaser", "tagline", "subtitle"}: + data.teaser = value + elif low == "quote_da": + data.quote_da = value.strip("\"“”") elif low in {"date", "dates", "when"}: data.date = value elif low in {"place", "location", "where"}: @@ -1060,7 +1066,7 @@ def build_video( filters.append(f"[{current}]" + ",".join(fade_parts) + f"[{fade_label}]") current = fade_label - title_lines = [x for x in [data.title, data.date, data.place] if x] + title_lines = [x for x in [data.title, data.teaser, data.date, data.place] if x] final_label = "vout" title_label = "titled" title_font = str(Path.home() / ".local/share/fonts/google/BebasNeue-Regular.ttf") @@ -1069,7 +1075,10 @@ def build_video( if title_lines: title_font_size = max(60, height // 10) subtitle_font_size = max(40, height // 18) + teaser_font_size = max(30, height // 24) + meta_font_size = max(24, height // 30) main_title = data.title or title_lines[0] + teaser = strip_unsupported_caption_chars((data.teaser or "").strip()) subtitle = " | ".join(x for x in [data.date, data.place] if x) fade_in_start = INTRO_TITLE_START_OFFSET fade_in_enabled = INTRO_TITLE_FADE_IN_ENABLED and INTRO_TITLE_FADE_LENGTH > 0 @@ -1099,34 +1108,39 @@ def build_video( ) title_enable_end = fade_out_end if fade_out_enabled else visible_end title_enable = f"enable='between(t,{fade_in_start:.3f},{title_enable_end:.3f})'" + + title_y = f"(h-text_h)/2-{title_font_size // 2}" + filters.append( + f"[{current}]drawtext=fontfile='{title_font}':{textfile_arg(main_title)}:x=(w-text_w)/2:y={title_y}:" + f"fontsize={title_font_size}:fontcolor=white:borderw=0:shadowcolor=black@0.75:shadowx=3:shadowy=3:" + f"alpha='{title_alpha}':{title_enable}[title0]" + ) + filters.append( + f"[title0]drawtext=fontfile='{title_font}':{textfile_arg(main_title)}:x=(w-text_w)/2+1:y={title_y}:" + f"fontsize={title_font_size}:fontcolor=white:borderw=0:shadowcolor=black@0.75:shadowx=3:shadowy=3:" + f"alpha='{title_alpha}':{title_enable}[title0b]" + ) + + title_next_label = "title0b" + if teaser: + teaser_y = f"(h-text_h)/2+{subtitle_font_size}" + filters.append( + f"[{title_next_label}]drawtext=fontfile='{title_font}':{textfile_arg(teaser)}:x=(w-text_w)/2:y={teaser_y}:" + f"fontsize={teaser_font_size}:fontcolor=0xF2F2EE:borderw=0:shadowcolor=black@0.75:shadowx=2:shadowy=2:" + f"alpha='{title_alpha}':{title_enable}[title_teaser]" + ) + title_next_label = "title_teaser" + if subtitle: - title_y = f"(h-text_h)/2-{title_font_size // 2}" + subtitle_y_offset = subtitle_font_size if not teaser else (subtitle_font_size + teaser_font_size + 8) + subtitle_size = subtitle_font_size if not teaser else meta_font_size filters.append( - f"[{current}]drawtext=fontfile='{title_font}':{textfile_arg(main_title)}:x=(w-text_w)/2:y={title_y}:" - f"fontsize={title_font_size}:fontcolor=white:borderw=0:shadowcolor=black@0.75:shadowx=3:shadowy=3:" - f"alpha='{title_alpha}':{title_enable}[title0]" - ) - filters.append( - f"[title0]drawtext=fontfile='{title_font}':{textfile_arg(main_title)}:x=(w-text_w)/2+1:y={title_y}:" - f"fontsize={title_font_size}:fontcolor=white:borderw=0:shadowcolor=black@0.75:shadowx=3:shadowy=3:" - f"alpha='{title_alpha}':{title_enable}[title0b]" - ) - filters.append( - f"[title0b]drawtext=fontfile='{title_font}':{textfile_arg(subtitle)}:x=(w-text_w)/2:y=(h-text_h)/2+{subtitle_font_size}:" - f"fontsize={subtitle_font_size}:fontcolor=white:borderw=0:shadowcolor=black@0.75:shadowx=2:shadowy=2:" + f"[{title_next_label}]drawtext=fontfile='{title_font}':{textfile_arg(subtitle)}:x=(w-text_w)/2:y=(h-text_h)/2+{subtitle_y_offset}:" + f"fontsize={subtitle_size}:fontcolor=white:borderw=0:shadowcolor=black@0.75:shadowx=2:shadowy=2:" f"alpha='{title_alpha}':{title_enable}[{title_label}]" ) else: - filters.append( - f"[{current}]drawtext=fontfile='{title_font}':{textfile_arg(main_title)}:x=(w-text_w)/2:y=(h-text_h)/2:" - f"fontsize={title_font_size}:fontcolor=white:borderw=0:shadowcolor=black@0.75:shadowx=3:shadowy=3:" - f"alpha='{title_alpha}':{title_enable}[title0]" - ) - filters.append( - f"[title0]drawtext=fontfile='{title_font}':{textfile_arg(main_title)}:x=(w-text_w)/2+1:y=(h-text_h)/2:" - f"fontsize={title_font_size}:fontcolor=white:borderw=0:shadowcolor=black@0.75:shadowx=3:shadowy=3:" - f"alpha='{title_alpha}':{title_enable}[{title_label}]" - ) + filters.append(f"[{title_next_label}]copy[{title_label}]") else: filters.append(f"[{current}]copy[{title_label}]") @@ -1289,10 +1303,12 @@ def build_video( cmd += ["-filter_complex", ";".join(filters), "-map", f"[{final_label}]"] metadata = { "title": data.title, + "teaser": data.teaser, "date": data.date, "location": data.place, "place": data.place, "com.apple.quicktime.location.name": data.place, + "quote_da": data.quote_da, "description": data.description, "synopsis": data.description, "artist": "Bubulescu.Org",