Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
107 lines
4.2 KiB
Python
107 lines
4.2 KiB
Python
"""The "Made with Menivor" end card (a short silent clip, spliced as the reel's outro).
|
|
|
|
Calm and plain on purpose: black background, the product name and address in
|
|
white, then "Made with Menivor" and menivor.com in grey. No emoji, no logo
|
|
art, so it reads on any feed. Built with ffmpeg ``drawtext``; text goes
|
|
through files (``textfile=``) so no product name can break the filter graph.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import subprocess
|
|
import tempfile
|
|
from dataclasses import dataclass
|
|
|
|
FONT_BOLD = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"
|
|
FONT_REGULAR = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
|
|
CARD_SECONDS = 3.0
|
|
WIDTH, HEIGHT = 1080, 1920
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class CardText:
|
|
name: str
|
|
address: str
|
|
tagline: str = "Made with Menivor"
|
|
footer: str = "menivor.com"
|
|
|
|
|
|
CARDS: dict[str, CardText] = {
|
|
"bidstage": CardText("Bidstage", "bidstage.app"),
|
|
"mail": CardText("Scribase Mail", "mail.scribase.com"),
|
|
"oxhan": CardText("Oxhan Atelier", "oxhanatelier.com"),
|
|
"alsat": CardText("Al-Sat", "alsat.ereboslab.com"),
|
|
"homeplan": CardText("HomePlan", "homeplan.subasiarhan3.workers.dev"),
|
|
"huddle": CardText("Huddle", "huddle-core.ereboslab.com/app"),
|
|
"caldesk": CardText("CalDesk AI", "caldeskai.com"),
|
|
"yokharita": CardText("Yokharita", "yokharita.com"),
|
|
"kamiko": CardText("Kamiko", "kamiko.fun"),
|
|
"menivor": CardText("Menivor", "menivor.com", tagline="Made with Menivor", footer="Make yours free"),
|
|
}
|
|
|
|
|
|
def _drawtext(textfile: str, font: str, size: int, color: str, y: str) -> str:
|
|
return (
|
|
f"drawtext=fontfile={font}:textfile={textfile}:fontsize={size}:fontcolor={color}"
|
|
f":x=(w-text_w)/2:y={y}"
|
|
)
|
|
|
|
|
|
#: DejaVuSans-Regular averages ~0.56em per character; this is the longest
|
|
#: address (chars) that still fits inside WIDTH at ADDRESS_FONT_MAX before
|
|
#: scaling down. A Vercel preview subdomain (e.g.
|
|
#: ``homeplan-arhansubas-projects.vercel.app``, 39 chars) is the real case
|
|
#: that first overflowed this at the fixed size (found running Megaphone on
|
|
#: HomePlan, 2026-11-07): at 56px it draws ~1,200px wide against a 1,080px
|
|
#: canvas, so the centered ``x=(w-text_w)/2`` goes negative and the card's
|
|
#: left/right edges clip off-screen.
|
|
ADDRESS_FONT_MAX = 56
|
|
ADDRESS_FONT_MIN = 30
|
|
ADDRESS_CHARS_AT_MAX = 24
|
|
_AVG_CHAR_EM = 0.56
|
|
|
|
|
|
def _address_font_size(address: str) -> int:
|
|
"""Shrinks the address line so it never overflows WIDTH, however long the real domain is."""
|
|
chars = len(address)
|
|
if chars <= ADDRESS_CHARS_AT_MAX:
|
|
return ADDRESS_FONT_MAX
|
|
budget = WIDTH * 0.92 # small side margin
|
|
fitted = int(budget / max(1, chars) / _AVG_CHAR_EM)
|
|
return max(ADDRESS_FONT_MIN, min(ADDRESS_FONT_MAX, fitted))
|
|
|
|
|
|
def build_command(card: CardText, out_path: str, workdir: str) -> list[str]:
|
|
"""The ffmpeg argv for ``card`` (text written to files under ``workdir``)."""
|
|
files = {}
|
|
for key, value in (("name", card.name), ("address", card.address), ("tagline", card.tagline), ("footer", card.footer)):
|
|
path = os.path.join(workdir, f"{key}.txt")
|
|
with open(path, "w", encoding="utf-8") as fh:
|
|
fh.write(value.replace("\n", " ").strip())
|
|
files[key] = path
|
|
vf = ",".join(
|
|
[
|
|
_drawtext(files["name"], FONT_BOLD, 104, "white", "h*0.40"),
|
|
_drawtext(files["address"], FONT_REGULAR, _address_font_size(card.address), "white@0.85", "h*0.40+150"),
|
|
_drawtext(files["tagline"], FONT_REGULAR, 44, "0x9a9a9a", "h*0.78"),
|
|
_drawtext(files["footer"], FONT_REGULAR, 38, "0x6e6e6e", "h*0.78+70"),
|
|
f"fade=t=in:st=0:d=0.35",
|
|
]
|
|
)
|
|
return [
|
|
"ffmpeg", "-hide_banner", "-loglevel", "error", "-y",
|
|
"-f", "lavfi", "-i", f"color=c=black:s={WIDTH}x{HEIGHT}:r=30:d={CARD_SECONDS}",
|
|
"-vf", vf, "-c:v", "libx264", "-pix_fmt", "yuv420p", "-preset", "veryfast",
|
|
"-movflags", "+faststart", "-an", out_path,
|
|
]
|
|
|
|
|
|
def render(product: str, out_path: str) -> str:
|
|
card = CARDS[product]
|
|
with tempfile.TemporaryDirectory(prefix="megaphone-card-") as work:
|
|
subprocess.run(build_command(card, out_path, work), check=True, timeout=120)
|
|
if not os.path.getsize(out_path):
|
|
raise RuntimeError(f"end card for {product} is empty")
|
|
return out_path
|