Use Bebas Neue and Inter fonts

This commit is contained in:
hbrain 2026-05-24 20:51:15 +00:00
parent ffc1974343
commit 0c1ee1c42a
2 changed files with 27 additions and 23 deletions

View file

@ -23,7 +23,9 @@ sudo apt install ffmpeg
The default title/stamp styling uses these fonts: The default title/stamp styling uses these fonts:
- Bebas Neue for the opening title, date, and location - Bebas Neue for the opening title, date, and location
- Montserrat for the bottom-left and bottom-right stamps - Inter for the bottom-left and bottom-right stamps
Both fonts support common Danish and Croatian characters such as `æ ø å Æ Ø Å č ć ž š đ Č Ć Ž Š Đ`.
Install them locally for the current user: Install them locally for the current user:
@ -31,16 +33,8 @@ Install them locally for the current user:
mkdir -p ~/.local/share/fonts/google mkdir -p ~/.local/share/fonts/google
curl -L -o ~/.local/share/fonts/google/BebasNeue-Regular.ttf \ curl -L -o ~/.local/share/fonts/google/BebasNeue-Regular.ttf \
'https://github.com/google/fonts/raw/main/ofl/bebasneue/BebasNeue-Regular.ttf' 'https://github.com/google/fonts/raw/main/ofl/bebasneue/BebasNeue-Regular.ttf'
curl -L -o ~/.local/share/fonts/google/Montserrat%5Bwght%5D.ttf \ curl -L -o ~/.local/share/fonts/google/Inter%5Bopsz,wght%5D.ttf \
'https://github.com/google/fonts/raw/main/ofl/montserrat/Montserrat%5Bwght%5D.ttf' 'https://github.com/google/fonts/raw/main/ofl/inter/Inter%5Bopsz,wght%5D.ttf'
fc-cache -f ~/.local/share/fonts/google
```
Optional font also used during experimentation:
```bash
curl -L -o ~/.local/share/fonts/google/Cinzel%5Bwght%5D.ttf \
'https://github.com/google/fonts/raw/main/ofl/cinzel/Cinzel%5Bwght%5D.ttf'
fc-cache -f ~/.local/share/fonts/google fc-cache -f ~/.local/share/fonts/google
``` ```
@ -48,8 +42,7 @@ Check that fonts are available:
```bash ```bash
fc-match 'Bebas Neue' fc-match 'Bebas Neue'
fc-match 'Montserrat' fc-match 'Inter'
fc-match 'Cinzel'
``` ```
## Input folder ## Input folder

View file

@ -386,47 +386,58 @@ def build_video(
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")
stamp_font = str(Path.home() / ".local/share/fonts/google/Montserrat%5Bwght%5D.ttf") stamp_font = str(Path.home() / ".local/share/fonts/google/Inter%5Bopsz,wght%5D.ttf")
if title_lines: if title_lines:
title_font_size = max(44, height // 14) title_font_size = max(50, height // 12)
subtitle_font_size = max(28, height // 24) subtitle_font_size = max(28, height // 24)
main_title = data.title or title_lines[0] main_title = data.title or title_lines[0]
subtitle = " | ".join(x for x in [data.date, data.place] if x) 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))" title_alpha = "if(lt(t\\,5)\\,1\\,if(lt(t\\,6)\\,6-t\\,0))"
if subtitle: if subtitle:
title_y = f"(h-text_h)/2-{title_font_size // 2}"
filters.append( filters.append(
f"[{current}]drawtext=fontfile='{title_font}':text='{drawtext_escape(main_title)}':x=(w-text_w)/2:y=(h-text_h)/2-{title_font_size // 2}:" f"[{current}]drawtext=fontfile='{title_font}':text='{drawtext_escape(main_title)}':x=(w-text_w)/2:y={title_y}:"
f"fontsize={title_font_size}:fontcolor=white:borderw=3:bordercolor=black:" f"fontsize={title_font_size}:text_spacing=4:fontcolor=white:borderw=3:bordercolor=black:"
f"alpha='{title_alpha}':enable='between(t,0,6)'[title0]" f"alpha='{title_alpha}':enable='between(t,0,6)'[title0]"
) )
filters.append( filters.append(
f"[title0]drawtext=fontfile='{title_font}':text='{drawtext_escape(subtitle)}':x=(w-text_w)/2:y=(h-text_h)/2+{subtitle_font_size}:" f"[title0]drawtext=fontfile='{title_font}':text='{drawtext_escape(main_title)}':x=(w-text_w)/2+1:y={title_y}:"
f"fontsize={title_font_size}:text_spacing=4:fontcolor=white:borderw=3:bordercolor=black:"
f"alpha='{title_alpha}':enable='between(t,0,6)'[title0b]"
)
filters.append(
f"[title0b]drawtext=fontfile='{title_font}':text='{drawtext_escape(subtitle)}':x=(w-text_w)/2:y=(h-text_h)/2+{subtitle_font_size}:"
f"fontsize={subtitle_font_size}:fontcolor=white:borderw=3:bordercolor=black:" f"fontsize={subtitle_font_size}:fontcolor=white:borderw=3:bordercolor=black:"
f"alpha='{title_alpha}':enable='between(t,0,6)'[{title_label}]" f"alpha='{title_alpha}':enable='between(t,0,6)'[{title_label}]"
) )
else: else:
filters.append( filters.append(
f"[{current}]drawtext=fontfile='{title_font}':text='{drawtext_escape(main_title)}':x=(w-text_w)/2:y=(h-text_h)/2:" f"[{current}]drawtext=fontfile='{title_font}':text='{drawtext_escape(main_title)}':x=(w-text_w)/2:y=(h-text_h)/2:"
f"fontsize={title_font_size}:fontcolor=white:borderw=3:bordercolor=black:" f"fontsize={title_font_size}:text_spacing=4:fontcolor=white:borderw=3:bordercolor=black:"
f"alpha='{title_alpha}':enable='between(t,0,6)'[title0]"
)
filters.append(
f"[title0]drawtext=fontfile='{title_font}':text='{drawtext_escape(main_title)}':x=(w-text_w)/2+1:y=(h-text_h)/2:"
f"fontsize={title_font_size}:text_spacing=4:fontcolor=white:borderw=3:bordercolor=black:"
f"alpha='{title_alpha}':enable='between(t,0,6)'[{title_label}]" f"alpha='{title_alpha}':enable='between(t,0,6)'[{title_label}]"
) )
else: else:
filters.append(f"[{current}]copy[{title_label}]") filters.append(f"[{current}]copy[{title_label}]")
stamp_size = max(14, height // 60) stamp_size = max(11, height // 80)
stamp_lines = [x for x in [data.title, data.date, data.place] if x] stamp_lines = [x for x in [data.title, data.date, data.place] if x]
stamp_text = drawtext_escape(" | ".join(stamp_lines)) stamp_text = drawtext_escape(" | ".join(stamp_lines))
stamp_left_label = "stamp_left" stamp_left_label = "stamp_left"
if stamp_text: if stamp_text:
filters.append( filters.append(
f"[{title_label}]drawtext=fontfile='{stamp_font}':text='{stamp_text}':x=24:y=h-text_h-18:" f"[{title_label}]drawtext=fontfile='{stamp_font}':text='{stamp_text}':x=24:y=h-text_h-18:"
f"fontsize={stamp_size}:fontcolor=white@0.92:borderw=2:bordercolor=black@0.85[{stamp_left_label}]" f"fontsize={stamp_size}:fontcolor=white:borderw=3:bordercolor=black[{stamp_left_label}]"
) )
else: else:
filters.append(f"[{title_label}]copy[{stamp_left_label}]") filters.append(f"[{title_label}]copy[{stamp_left_label}]")
filters.append( filters.append(
f"[{stamp_left_label}]drawtext=fontfile='{stamp_font}':text='marijo@novosel.dk':x=w-text_w-24:y=h-text_h-18:" f"[{stamp_left_label}]drawtext=fontfile='{stamp_font}':text='@bubulescu':x=w-text_w-24:y=h-text_h-18:"
f"fontsize={stamp_size}:fontcolor=white@0.92:borderw=2:bordercolor=black@0.85[{final_label}]" f"fontsize={stamp_size}:fontcolor=white:borderw=3:bordercolor=black[{final_label}]"
) )
cmd += ["-filter_complex", ";".join(filters), "-map", f"[{final_label}]"] cmd += ["-filter_complex", ";".join(filters), "-map", f"[{final_label}]"]