Embed teaser and quote_da metadata only in rendered videos
This commit is contained in:
parent
7a9a90e71e
commit
f43f6f3ef4
1 changed files with 40 additions and 24 deletions
44
movmaker.py
44
movmaker.py
|
|
@ -85,6 +85,8 @@ def tool_path(local_path: Path, fallback: str) -> str:
|
||||||
@dataclass
|
@dataclass
|
||||||
class MovieData:
|
class MovieData:
|
||||||
title: str = ""
|
title: str = ""
|
||||||
|
teaser: str = ""
|
||||||
|
quote_da: str = ""
|
||||||
date: str = ""
|
date: str = ""
|
||||||
place: str = ""
|
place: str = ""
|
||||||
description: str = ""
|
description: str = ""
|
||||||
|
|
@ -698,6 +700,10 @@ def parse_data_file(path: Path | None) -> MovieData:
|
||||||
continue
|
continue
|
||||||
if low in {"title", "name"}:
|
if low in {"title", "name"}:
|
||||||
data.title = value
|
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"}:
|
elif low in {"date", "dates", "when"}:
|
||||||
data.date = value
|
data.date = value
|
||||||
elif low in {"place", "location", "where"}:
|
elif low in {"place", "location", "where"}:
|
||||||
|
|
@ -1060,7 +1066,7 @@ def build_video(
|
||||||
filters.append(f"[{current}]" + ",".join(fade_parts) + f"[{fade_label}]")
|
filters.append(f"[{current}]" + ",".join(fade_parts) + f"[{fade_label}]")
|
||||||
current = 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"
|
final_label = "vout"
|
||||||
title_label = "titled"
|
title_label = "titled"
|
||||||
title_font = str(Path.home() / ".local/share/fonts/google/BebasNeue-Regular.ttf")
|
title_font = str(Path.home() / ".local/share/fonts/google/BebasNeue-Regular.ttf")
|
||||||
|
|
@ -1069,7 +1075,10 @@ def build_video(
|
||||||
if title_lines:
|
if title_lines:
|
||||||
title_font_size = max(60, height // 10)
|
title_font_size = max(60, height // 10)
|
||||||
subtitle_font_size = max(40, height // 18)
|
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]
|
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)
|
subtitle = " | ".join(x for x in [data.date, data.place] if x)
|
||||||
fade_in_start = INTRO_TITLE_START_OFFSET
|
fade_in_start = INTRO_TITLE_START_OFFSET
|
||||||
fade_in_enabled = INTRO_TITLE_FADE_IN_ENABLED and INTRO_TITLE_FADE_LENGTH > 0
|
fade_in_enabled = INTRO_TITLE_FADE_IN_ENABLED and INTRO_TITLE_FADE_LENGTH > 0
|
||||||
|
|
@ -1099,7 +1108,7 @@ def build_video(
|
||||||
)
|
)
|
||||||
title_enable_end = fade_out_end if fade_out_enabled else visible_end
|
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_enable = f"enable='between(t,{fade_in_start:.3f},{title_enable_end:.3f})'"
|
||||||
if subtitle:
|
|
||||||
title_y = f"(h-text_h)/2-{title_font_size // 2}"
|
title_y = f"(h-text_h)/2-{title_font_size // 2}"
|
||||||
filters.append(
|
filters.append(
|
||||||
f"[{current}]drawtext=fontfile='{title_font}':{textfile_arg(main_title)}:x=(w-text_w)/2:y={title_y}:"
|
f"[{current}]drawtext=fontfile='{title_font}':{textfile_arg(main_title)}:x=(w-text_w)/2:y={title_y}:"
|
||||||
|
|
@ -1111,22 +1120,27 @@ def build_video(
|
||||||
f"fontsize={title_font_size}:fontcolor=white:borderw=0:shadowcolor=black@0.75:shadowx=3:shadowy=3:"
|
f"fontsize={title_font_size}:fontcolor=white:borderw=0:shadowcolor=black@0.75:shadowx=3:shadowy=3:"
|
||||||
f"alpha='{title_alpha}':{title_enable}[title0b]"
|
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(
|
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"[{title_next_label}]drawtext=fontfile='{title_font}':{textfile_arg(teaser)}:x=(w-text_w)/2:y={teaser_y}:"
|
||||||
f"fontsize={subtitle_font_size}:fontcolor=white:borderw=0:shadowcolor=black@0.75:shadowx=2:shadowy=2:"
|
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:
|
||||||
|
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"[{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}]"
|
f"alpha='{title_alpha}':{title_enable}[{title_label}]"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
filters.append(
|
filters.append(f"[{title_next_label}]copy[{title_label}]")
|
||||||
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}]"
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
filters.append(f"[{current}]copy[{title_label}]")
|
filters.append(f"[{current}]copy[{title_label}]")
|
||||||
|
|
||||||
|
|
@ -1289,10 +1303,12 @@ def build_video(
|
||||||
cmd += ["-filter_complex", ";".join(filters), "-map", f"[{final_label}]"]
|
cmd += ["-filter_complex", ";".join(filters), "-map", f"[{final_label}]"]
|
||||||
metadata = {
|
metadata = {
|
||||||
"title": data.title,
|
"title": data.title,
|
||||||
|
"teaser": data.teaser,
|
||||||
"date": data.date,
|
"date": data.date,
|
||||||
"location": data.place,
|
"location": data.place,
|
||||||
"place": data.place,
|
"place": data.place,
|
||||||
"com.apple.quicktime.location.name": data.place,
|
"com.apple.quicktime.location.name": data.place,
|
||||||
|
"quote_da": data.quote_da,
|
||||||
"description": data.description,
|
"description": data.description,
|
||||||
"synopsis": data.description,
|
"synopsis": data.description,
|
||||||
"artist": "Bubulescu.Org",
|
"artist": "Bubulescu.Org",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue