adopt_video: optional per-clip ADOPT options (tween, shade)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-10-14 20:37:06 +02:00
parent 3b39dbce0b
commit 052a56bc11

View File

@@ -11,11 +11,16 @@ Sidebar scenes (scene_*) are a slow loop in the game's left column instead: no
vignette and no in-between frames, but the same darkening towards the bottom the
still image had (MainForm.SceneBitmap), so it blends into the dark column.
Optional per clip, ADOPT = {name: {"tween": bool, "shade": 0..255}} in the project's
VIDEO_MODULE: tween=False keeps the 49 raw frames (slow loops, half the size), shade
darkens every frame by that alpha of black (to match a dimmed backdrop in the game).
Usage:
py -3.12 adopt_video.py every clip that has frames
py -3.12 adopt_video.py story_old just one
"""
import glob
import importlib
import os
import sys
@@ -26,6 +31,7 @@ from PIL import Image, ImageDraw, ImageFilter
import _bootstrap # Projektordner (config.py, Listen) vor allen anderen Modulen
import config
ADOPT = getattr(importlib.import_module(getattr(config, "VIDEO_MODULE", "video_life")), "ADOPT", {})
SRC = os.path.join(config.OUTPUT_DIR, "video")
DEST = os.path.join(config.ASSETS_DIR, "Video")
QUALITY = 80
@@ -82,7 +88,8 @@ def adopt(name):
os.remove(old)
raw = [np.asarray(Image.open(f).convert("RGB")) for f in frames]
scene = name.startswith("scene_")
if not scene:
opts = ADOPT.get(name, {})
if opts.get("tween", not scene):
raw = interpolate(raw)
size = (raw[0].shape[1], raw[0].shape[0])
mask = bottom_shade(size) if scene else vignette(size)
@@ -90,6 +97,8 @@ def adopt(name):
total = 0
for i, arr in enumerate(raw):
im = Image.composite(black, Image.fromarray(arr), mask)
if opts.get("shade"):
im = Image.composite(Image.new("RGB", size, (0, 0, 0)), im, Image.new("L", size, opts["shade"]))
p = os.path.join(DEST, f"{name}_{i:02d}.jpg")
im.save(p, quality=QUALITY, optimize=True)
total += os.path.getsize(p)