Files
LihonT/scripts/promo3d/compose.py
cheb0chik b78266d40c LihonT 3 Luna beta 1: the site look, the floating island, full-screen video and the agent
The "Как сайт" look by default, also in TikTok's settings and all their sub-pages, where every item is its own rounded row.
The bottom bar floats as an island, 9:16 videos reach under it, the seek bar is lifted, thicker and on by default, the
comment input is an island too, and "only sound" downloads are saved as audio. The LihonT agent: a chat that makes cards and
slides for a photo post, looks things up on the web, signs in with Telegram and has a daily limit on the server. Also the
нейронка.рус landing page and the 3D-phone promo scripts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 16:10:45 +03:00

93 lines
3.3 KiB
Python

"""Lays the rendered phone frames on a light ground, adds the captions on the beats and the sound, writes the mp4."""
import glob
import subprocess
import sys
from PIL import Image, ImageDraw, ImageFont
FRAMES = sorted(glob.glob("frames2/f_*.png"))
AUDIO = sys.argv[1]
OUT = sys.argv[2]
FPS = 30
W, H = 1080, 1920
GROUND = (244, 244, 246)
INK = (13, 13, 15)
MUTED = (110, 110, 118)
F = "C:/Windows/Fonts/"
def font(size, bold=True):
return ImageFont.truetype(F + ("segoeuib.ttf" if bold else "segoeui.ttf"), size)
# (start, end, big line, small line)
CAPTIONS = [
(1.14, 3.18, "Остров вместо панели", "видео на весь экран"),
(3.18, 5.25, "Новый вид «Как сайт»", "спокойный и чистый"),
(5.25, 7.29, "Каждый пункт отдельно", "все настройки TikTok"),
(7.29, 9.36, "ИИ-агент", "делает карточки для поста"),
(9.36, 11.42, "Пара секунд —", "и пост готов"),
]
def ease(x):
x = max(0.0, min(1.0, x))
return 1 - (1 - x) ** 3
def caption(img, t, start, end, big, small):
fade = 0.18
a = min(ease((t - start) / fade), ease((end - t) / fade))
if a <= 0:
return
rise = (1 - ease((t - start) / 0.3)) * 30
layer = Image.new("RGBA", (W, H), (0, 0, 0, 0))
d = ImageDraw.Draw(layer)
d.text((W / 2, 170 + rise), big, font=font(78), fill=INK + (int(255 * a),), anchor="mm")
d.text((W / 2, 262 + rise), small, font=font(46, False), fill=MUTED + (int(255 * a),), anchor="mm")
img.alpha_composite(layer)
def title(img, t):
"""The name at the start (until the first scene) and at the end (after the phone has gone)."""
if t < 1.3:
a = min(ease(t / 0.25), ease((1.3 - t) / 0.2))
y = 170
size = 92
elif t > 11.9:
a = ease((t - 11.9) / 0.35)
y = H / 2 - 60
size = 120
else:
return
layer = Image.new("RGBA", (W, H), (0, 0, 0, 0))
d = ImageDraw.Draw(layer)
d.text((W / 2, y), "LihonT 3", font=font(size), fill=INK + (int(255 * a),), anchor="mm")
d.text((W / 2, y + size * 0.95), "Luna beta 1", font=font(int(size * 0.55), False), fill=MUTED + (int(255 * a),), anchor="mm")
if t > 11.9:
d.text((W / 2, y + size * 1.9), "lihont.space", font=font(48), fill=INK + (int(230 * a),), anchor="mm")
img.alpha_composite(layer)
def main():
cmd = ["ffmpeg", "-loglevel", "error", "-y", "-f", "rawvideo", "-pix_fmt", "rgb24", "-s", f"{W}x{H}", "-r", str(FPS),
"-i", "-", "-i", AUDIO, "-map", "0:v", "-map", "1:a", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-crf", "17",
"-preset", "slow", "-c:a", "aac", "-b:a", "192k", "-shortest", "-movflags", "+faststart", OUT]
pipe = subprocess.Popen(cmd, stdin=subprocess.PIPE)
for i, path in enumerate(FRAMES):
t = i / FPS
img = Image.new("RGBA", (W, H), GROUND + (255,))
phone = Image.open(path).convert("RGBA")
img.alpha_composite(phone)
title(img, t)
for start, end, big, small in CAPTIONS:
if start - 0.01 <= t <= end + 0.01:
caption(img, t, start, end, big, small)
pipe.stdin.write(img.convert("RGB").tobytes())
pipe.stdin.close()
pipe.wait()
print("written", OUT)
main()