diff --git a/README.md b/README.md index 20e30892e..79d6035cd 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,9 @@ listing language. `design/promo-film/` holds the trailer's sources: `film.json` (clips, voice times, app-screen inserts), `narrate.py` (Lumi's voice), `score.py` (music), `mix.py`, `keyframes.py` and `compose.py`, which renders the cut with the real -app screens into `build/promo-video/`. +app screens into `build/promo-video/`. `mix.py --short` and +`compose.py --short` render the 36-second vertical short from `short.json`, +the portrait keyframes in `keyframes-vertical/` and sections of the same score. Screenshot publishing still requires the complete current capture, visual review, export and locked build preflight. diff --git a/design/promo-film/compose.py b/design/promo-film/compose.py index d6cc2defa..cc1361776 100644 --- a/design/promo-film/compose.py +++ b/design/promo-film/compose.py @@ -3,6 +3,7 @@ compose.py --animatic storyboard keyframes with slow camera moves compose.py --base FILM.mp4 the generated film (16:9, cut to the soundtrack) + compose.py --short the 1080x1920 vertical short from short.json Options: --from S --to S render a range, --still S writes one frame as PNG. Output goes to build/promo-video/. @@ -23,6 +24,7 @@ BUILD = ROOT / "build/promo-video" SCREENS = ROOT / "fastlane/metadata/android/en-US/images/phoneScreenshots" SUN_FRAMES = ROOT / "assets/practices/sunsalutation/characters/01-sunrise-ponytail" WIDTH, HEIGHT, FPS = 1920, 1080, 24 +KEYFRAMES = HERE / "keyframes" APP_BACKGROUND = (245, 248, 246) APP_TEXT = (31, 42, 40) NOTO = "/usr/share/fonts/truetype/noto/NotoSans-Regular.ttf" @@ -113,7 +115,10 @@ def tai_chi_screen(local, key, title, subtitle, video): screen = capture("04-sun-salutation").copy() blank(screen, (290, 40, 800, 160)) blank(screen, (0, 190, 1080, 1780)) - centered_text(screen, title, 556, 74, font(NOTO, 50)) + size = 50 + while ImageDraw.Draw(screen).textlength(title, font=font(NOTO, size)) > 470: + size -= 2 + centered_text(screen, title, 556, 74 + (50 - size) // 2, font(NOTO, size)) centered_text(screen, subtitle, 540, 231, font(NOTO, 36)) frame = LESSONS[key].next() if frame is not None: @@ -178,7 +183,11 @@ def place_phone(frame, device, side, local, length): if alpha <= 0: return float_y = 6 * math.sin(2 * math.pi * local / 4.5) - if side == "center": + if side == "bottom": + # Vertical short: lower centre, left of TikTok's buttons, rising in. + x = round(480 - device.width / 2) + y = round(1590 - PHONE_H - SHADOW_PAD + float_y + 240 * (1 - enter) + 90 * leave) + elif side == "center": # An app reveal: the scene softens behind a phone rising into the middle. soft = frame.filter(ImageFilter.GaussianBlur(16 * alpha)) dark = Image.new("RGBA", frame.size, (8, 12, 24, round(110 * alpha))) @@ -228,9 +237,42 @@ def end_card(): return card +@lru_cache(None) +def end_card_vertical(): + card = Image.new("RGBA", (WIDTH, HEIGHT), (0, 0, 0, 0)) + shade = np.zeros((HEIGHT, WIDTH, 4), np.uint8) + rows = np.linspace(0, 1, HEIGHT) + title = np.clip(1 - np.abs(rows - 0.33) / 0.3, 0, 1) ** 1.4 * 150 + footer = np.clip(1 - np.abs(rows - 0.7) / 0.14, 0, 1) ** 1.2 * 170 + shade[..., 3] = np.maximum(title, footer)[:, None] + shade[..., :3] = (6, 12, 30) + card.alpha_composite(Image.fromarray(shade, "RGBA")) + center = 520 + glow = Image.new("RGBA", (WIDTH, HEIGHT), (0, 0, 0, 0)) + ImageDraw.Draw(glow).ellipse((center - 210, 300, center + 210, 680), fill=(255, 214, 140, 70)) + card.alpha_composite(glow.filter(ImageFilter.GaussianBlur(60))) + logo = Image.open(ROOT / "assets/app/source-icon.png").convert("RGBA").resize((330, 330), Image.LANCZOS) + card.alpha_composite(logo, (center - 165, 330)) + centered_text(card, "Inner Breeze", center, 720, font(QUICKSAND_BOLD, 124), (255, 250, 238, 255)) + centered_text(card, "Breathe · Move · Grow", center, 880, font(QUICKSAND_MEDIUM, 50), (247, 220, 160, 255)) + badges = [Image.open(ROOT / f"assets/app/badge-{name}.png").convert("RGBA") for name in ("google-play", "f-droid")] + badges = [badge.resize((round(badge.width * 100 / badge.height), 100), Image.LANCZOS) for badge in badges] + gap = 26 + x = center - (sum(badge.width for badge in badges) + gap) // 2 + for badge in badges: + card.alpha_composite(badge, (x, 1270)) + x += badge.width + gap + centered_text(card, "Free, private and open source", center, 1410, font(QUICKSAND_MEDIUM, 40), (232, 236, 246, 255)) + return card + + def keyframe(shot): - image = Image.open(HERE / "keyframes" / f"shot-{shot:02d}.jpg").convert("RGB") - band = round(image.width * 9 / 16) + image = Image.open(KEYFRAMES / f"shot-{shot:02d}.jpg").convert("RGB") + if image.width * HEIGHT > image.height * WIDTH: + band = round(image.height * WIDTH / HEIGHT) + left = (image.width - band) // 2 + return image.crop((left, 0, left + band, image.height)) + band = round(image.width * HEIGHT / WIDTH) top = (image.height - band) // 2 return image.crop((0, top, image.width, top + band)) @@ -252,6 +294,19 @@ def animatic_frame(film, time): return crop.resize((WIDTH, HEIGHT), Image.BILINEAR) +def insert_screen(insert, local): + """The insert's screen at this moment; one phone can change screens.""" + screens = insert.get("screens") or [[insert["screen"], 0.0]] + current = [index for index, (name, at) in enumerate(screens) if at <= local][-1] + screen = INSERTS[screens[current][0]](local - screens[current][1]) + if current > 0: + mix = ease_in_out((local - screens[current][1]) / 0.35) + if mix < 1: + previous = INSERTS[screens[current - 1][0]](local - screens[current - 1][1]) + screen = Image.blend(previous.convert("RGB"), screen.convert("RGB"), mix) + return screen + + def main(): parser = argparse.ArgumentParser() parser.add_argument("--animatic", action="store_true") @@ -259,12 +314,18 @@ def main(): parser.add_argument("--start", type=float, default=0.0) parser.add_argument("--end", type=float) parser.add_argument("--still", type=float) + parser.add_argument("--short", action="store_true") parser.add_argument("--out") args = parser.parse_args() - film = json.loads((HERE / "film.json").read_text()) + global WIDTH, HEIGHT, KEYFRAMES + if args.short: + WIDTH, HEIGHT, KEYFRAMES = 1080, 1920, HERE / "keyframes-vertical" + film = json.loads((HERE / ("short.json" if args.short else "film.json")).read_text()) length = film["format"]["length"] end = args.end if args.end is not None else length - name = "inner-breeze-a-day-with-lumi" + ("-animatic" if args.animatic else "") + name = "inner-breeze-a-day-with-lumi" + ("-short" if args.short else "-animatic" if args.animatic else "") + soundtrack = BUILD / ("audio/short-soundtrack.wav" if args.short else "audio/soundtrack.wav") + card_at = film.get("end_card", 59.0) out = Path(args.out) if args.out else BUILD / f"{name}.mp4" base = None if args.base: @@ -276,7 +337,7 @@ def main(): writer = subprocess.Popen( ["ffmpeg", "-loglevel", "error", "-y", "-f", "rawvideo", "-pix_fmt", "rgb24", "-s", f"{WIDTH}x{HEIGHT}", "-r", str(FPS), "-i", "-", "-ss", str(args.start), "-to", str(end), - "-i", str(BUILD / "audio/soundtrack.wav"), "-map", "0:v", "-map", "1:a", "-c:v", "libx264", "-preset", + "-i", str(soundtrack), "-map", "0:v", "-map", "1:a", "-c:v", "libx264", "-preset", "slow", "-crf", "17", "-pix_fmt", "yuv420p", "-c:a", "aac", "-b:a", "256k", "-movflags", "+faststart", "-shortest", str(out)], stdin=subprocess.PIPE) first = round(args.start * FPS) @@ -295,11 +356,11 @@ def main(): for insert in film["inserts"]: start, stop = insert["from"], insert["to"] if start <= time < stop: - device = phone(INSERTS[insert["screen"]](time - start)) + device = phone(insert_screen(insert, time - start)) place_phone(frame, device, insert["side"], time - start, stop - start) - if time >= 59.0: - card = end_card() - fade = ease_in_out((time - 59.0) / 0.9) + if time >= card_at: + card = end_card_vertical() if args.short else end_card() + fade = ease_in_out((time - card_at) / 0.9) if fade < 1: card = card.copy() card.putalpha(card.getchannel("A").point(lambda value: round(value * fade))) diff --git a/design/promo-film/keyframes-vertical.json b/design/promo-film/keyframes-vertical.json new file mode 100644 index 000000000..235aa268c --- /dev/null +++ b/design/promo-film/keyframes-vertical.json @@ -0,0 +1,82 @@ +[ + { + "shot": 1, + "refs": [ + "keyframe-01", + "lumi" + ], + "prompt": "Vertical phone-video keyframe for an animated promo. Recompose the first input image (the approved storyboard frame) as a tall vertical frame: same scene, setting, lighting, characters and painted style. Lumi rises from the reeds at blue hour above the misty lake, glowing, smiling and waving at the viewer. Lumi large in the middle of the frame. Premium hand-painted storybook 3D animation still, soft watercolor texture, warm cinematic light, gentle haze. Keep every character exactly like the other input images. Tall 2:3 portrait canvas; keep important content inside the central vertical band so the left and right 8 percent can be cropped. No text, letters, logos, watermarks, UI or readable screens." + }, + { + "shot": 2, + "refs": [ + "keyframe-02", + "lumi", + "mia" + ], + "prompt": "Vertical phone-video keyframe for an animated promo. Recompose the first input image (the approved storyboard frame) as a tall vertical frame: same scene, setting, lighting, characters and painted style. Sunrise in the cozy wooden cabin bedroom: Mia stretches in bed and smiles at Lumi fluttering in by the open window. Place the characters in the upper 55 percent of the frame and keep the lower 40 percent calm and simple (soft ground, water, bedding or floor), because an app screen is shown there. Premium hand-painted storybook 3D animation still, soft watercolor texture, warm cinematic light, gentle haze. Keep every character exactly like the other input images. Tall 2:3 portrait canvas; keep important content inside the central vertical band so the left and right 8 percent can be cropped. No text, letters, logos, watermarks, UI or readable screens." + }, + { + "shot": 3, + "refs": [ + "keyframe-03", + "lumi", + "mia" + ], + "prompt": "Vertical phone-video keyframe for an animated promo. Recompose the first input image (the approved storyboard frame) as a tall vertical frame: same scene, setting, lighting, characters and painted style. Mia breathing on the wooden dock over the misty lake at sunrise, eyes closed, breath visible, Lumi glowing beside her. Place the characters in the upper 55 percent of the frame and keep the lower 40 percent calm and simple (soft ground, water, bedding or floor), because an app screen is shown there. Premium hand-painted storybook 3D animation still, soft watercolor texture, warm cinematic light, gentle haze. Keep every character exactly like the other input images. Tall 2:3 portrait canvas; keep important content inside the central vertical band so the left and right 8 percent can be cropped. No text, letters, logos, watermarks, UI or readable screens." + }, + { + "shot": 5, + "refs": [ + "keyframe-05", + "lumi", + "mia" + ], + "prompt": "Vertical phone-video keyframe for an animated promo. Recompose the first input image (the approved storyboard frame) as a tall vertical frame: same scene, setting, lighting, characters and painted style. Mia in upward salute on a sunlit mountain meadow, Lumi tracing a golden arc along her raised arms. Place the characters in the upper 55 percent of the frame and keep the lower 40 percent calm and simple (soft ground, water, bedding or floor), because an app screen is shown there. Premium hand-painted storybook 3D animation still, soft watercolor texture, warm cinematic light, gentle haze. Keep every character exactly like the other input images. Tall 2:3 portrait canvas; keep important content inside the central vertical band so the left and right 8 percent can be cropped. No text, letters, logos, watermarks, UI or readable screens." + }, + { + "shot": 6, + "refs": [ + "keyframe-06", + "monk", + "mia" + ], + "prompt": "Vertical phone-video keyframe for an animated promo. Recompose the first input image (the approved storyboard frame) as a tall vertical frame: same scene, setting, lighting, characters and painted style. The monk and Mia doing Tai Chi Wave Hands Like Clouds side by side in the misty Himalayan monastery courtyard with prayer flags. Place the characters in the upper 55 percent of the frame and keep the lower 40 percent calm and simple (soft ground, water, bedding or floor), because an app screen is shown there. Premium hand-painted storybook 3D animation still, soft watercolor texture, warm cinematic light, gentle haze. Keep every character exactly like the other input images. Tall 2:3 portrait canvas; keep important content inside the central vertical band so the left and right 8 percent can be cropped. No text, letters, logos, watermarks, UI or readable screens." + }, + { + "shot": 7, + "refs": [ + "keyframe-07", + "teacher", + "monk", + "lumi" + ], + "prompt": "Vertical phone-video keyframe for an animated promo. Recompose the first input image (the approved storyboard frame) as a tall vertical frame: same scene, setting, lighting, characters and painted style. Dolma and the monk doing Brush Knee and Push in unison in the same monastery courtyard, Lumi drawing a golden ribbon along their hands. Place the characters in the upper 55 percent of the frame and keep the lower 40 percent calm and simple (soft ground, water, bedding or floor), because an app screen is shown there. Premium hand-painted storybook 3D animation still, soft watercolor texture, warm cinematic light, gentle haze. Keep every character exactly like the other input images. Tall 2:3 portrait canvas; keep important content inside the central vertical band so the left and right 8 percent can be cropped. No text, letters, logos, watermarks, UI or readable screens." + }, + { + "shot": 9, + "refs": [ + "keyframe-09", + "lumi", + "mia" + ], + "prompt": "Vertical phone-video keyframe for an animated promo. Recompose the first input image (the approved storyboard frame) as a tall vertical frame: same scene, setting, lighting, characters and painted style. Mia at her cozy desk by the rainy window in warm lamp light, writing in her journal, a row of small floating golden circles of light above the desk, Lumi on the lamp shade. Place the characters in the upper 55 percent of the frame and keep the lower 40 percent calm and simple (soft ground, water, bedding or floor), because an app screen is shown there. Premium hand-painted storybook 3D animation still, soft watercolor texture, warm cinematic light, gentle haze. Keep every character exactly like the other input images. Tall 2:3 portrait canvas; keep important content inside the central vertical band so the left and right 8 percent can be cropped. No text, letters, logos, watermarks, UI or readable screens." + }, + { + "shot": 10, + "refs": [ + "keyframe-10", + "lumi", + "mia" + ], + "prompt": "Vertical phone-video keyframe for an animated promo. Recompose the first input image (the approved storyboard frame) as a tall vertical frame: same scene, setting, lighting, characters and painted style. Night: Mia curled on the sofa under a knitted blanket with her phone, Lumi glowing beside her face, both smiling. Place the characters in the upper 55 percent of the frame and keep the lower 40 percent calm and simple (soft ground, water, bedding or floor), because an app screen is shown there. Premium hand-painted storybook 3D animation still, soft watercolor texture, warm cinematic light, gentle haze. Keep every character exactly like the other input images. Tall 2:3 portrait canvas; keep important content inside the central vertical band so the left and right 8 percent can be cropped. No text, letters, logos, watermarks, UI or readable screens." + }, + { + "shot": 11, + "refs": [ + "keyframe-11", + "lumi" + ], + "prompt": "Vertical phone-video keyframe for an animated promo. Recompose the first input image (the approved storyboard frame) as a tall vertical frame: same scene, setting, lighting, characters and painted style. Starry night above the calm lake, Lumi flying upward leaving a long curling golden trail. Keep the middle of the frame dark and open for a title. Premium hand-painted storybook 3D animation still, soft watercolor texture, warm cinematic light, gentle haze. Keep every character exactly like the other input images. Tall 2:3 portrait canvas; keep important content inside the central vertical band so the left and right 8 percent can be cropped. No text, letters, logos, watermarks, UI or readable screens." + } +] diff --git a/design/promo-film/keyframes-vertical/shot-01.jpg b/design/promo-film/keyframes-vertical/shot-01.jpg new file mode 100644 index 000000000..7988a87b8 Binary files /dev/null and b/design/promo-film/keyframes-vertical/shot-01.jpg differ diff --git a/design/promo-film/keyframes-vertical/shot-02.jpg b/design/promo-film/keyframes-vertical/shot-02.jpg new file mode 100644 index 000000000..d02c6d989 Binary files /dev/null and b/design/promo-film/keyframes-vertical/shot-02.jpg differ diff --git a/design/promo-film/keyframes-vertical/shot-03.jpg b/design/promo-film/keyframes-vertical/shot-03.jpg new file mode 100644 index 000000000..34de7fd2a Binary files /dev/null and b/design/promo-film/keyframes-vertical/shot-03.jpg differ diff --git a/design/promo-film/keyframes-vertical/shot-05.jpg b/design/promo-film/keyframes-vertical/shot-05.jpg new file mode 100644 index 000000000..f6ac1b112 Binary files /dev/null and b/design/promo-film/keyframes-vertical/shot-05.jpg differ diff --git a/design/promo-film/keyframes-vertical/shot-06.jpg b/design/promo-film/keyframes-vertical/shot-06.jpg new file mode 100644 index 000000000..b7f36f5b1 Binary files /dev/null and b/design/promo-film/keyframes-vertical/shot-06.jpg differ diff --git a/design/promo-film/keyframes-vertical/shot-07.jpg b/design/promo-film/keyframes-vertical/shot-07.jpg new file mode 100644 index 000000000..9f709fcc0 Binary files /dev/null and b/design/promo-film/keyframes-vertical/shot-07.jpg differ diff --git a/design/promo-film/keyframes-vertical/shot-09.jpg b/design/promo-film/keyframes-vertical/shot-09.jpg new file mode 100644 index 000000000..01aca7e5d Binary files /dev/null and b/design/promo-film/keyframes-vertical/shot-09.jpg differ diff --git a/design/promo-film/keyframes-vertical/shot-10.jpg b/design/promo-film/keyframes-vertical/shot-10.jpg new file mode 100644 index 000000000..5cf290670 Binary files /dev/null and b/design/promo-film/keyframes-vertical/shot-10.jpg differ diff --git a/design/promo-film/keyframes-vertical/shot-11.jpg b/design/promo-film/keyframes-vertical/shot-11.jpg new file mode 100644 index 000000000..f5dd76d9c Binary files /dev/null and b/design/promo-film/keyframes-vertical/shot-11.jpg differ diff --git a/design/promo-film/keyframes.py b/design/promo-film/keyframes.py index ed7104b37..b117f8b43 100644 --- a/design/promo-film/keyframes.py +++ b/design/promo-film/keyframes.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """Paint one storyboard keyframe per shot with Codex image generation. -Usage: keyframes.py [SHOT...]. Writes build/promo-video/keyframes/shot-NN.png +Usage: keyframes.py [--vertical] [SHOT...]. Writes build/promo-video/keyframes/shot-NN.png (1536x1024 from Codex; the film uses its central 16:9 band). Runs up to four Codex sessions at once and keeps existing keyframes unless named. Approved keyframes are stored as 1536x864 JPEGs in keyframes/ beside this @@ -30,8 +30,8 @@ IMAGES = Path.home() / ".codex/generated_images" def paint(frame): target = OUT / f"shot-{frame['shot']:02d}.png" log = OUT / f"shot-{frame['shot']:02d}.log" - # "keyframe-NN" names an earlier shot's painted keyframe, for continuity. - images = [str(OUT / f"shot-{name[9:]}.png") if name.startswith("keyframe-") else str(REFERENCES[name]) + # "keyframe-NN" names an approved landscape keyframe, for continuity. + images = [str(HERE / "keyframes" / f"shot-{name[9:]}.jpg") if name.startswith("keyframe-") else str(REFERENCES[name]) for name in frame["refs"]] with open(log, "w") as output: subprocess.run(["codex", "exec", "--skip-git-repo-check", "--sandbox", "read-only", "-C", str(OUT), @@ -46,9 +46,13 @@ def paint(frame): def main(): + global OUT + vertical = "--vertical" in sys.argv + if vertical: + OUT = ROOT / "build/promo-video/keyframes-vertical" OUT.mkdir(parents=True, exist_ok=True) - frames = json.loads((HERE / "keyframes.json").read_text()) - wanted = {int(arg) for arg in sys.argv[1:]} + frames = json.loads((HERE / ("keyframes-vertical.json" if vertical else "keyframes.json")).read_text()) + wanted = {int(arg) for arg in sys.argv[1:] if not arg.startswith("--")} todo = [frame for frame in frames if (frame["shot"] in wanted) or (not wanted and not (OUT / f"shot-{frame['shot']:02d}.png").exists())] with ThreadPoolExecutor(4) as pool: diff --git a/design/promo-film/mix.py b/design/promo-film/mix.py index d540f997b..63a7bcf09 100644 --- a/design/promo-film/mix.py +++ b/design/promo-film/mix.py @@ -3,10 +3,12 @@ Reads the chosen takes and score from audio/ beside this script and writes build/promo-video/audio/soundtrack.wav (48 kHz stereo, -14 LUFS) and -soundtrack.mp3, the audio the film is cut to. +soundtrack.mp3, the audio the film is cut to. --short mixes short.json, the +vertical short, into short-soundtrack.wav/.mp3. """ import json import subprocess +import sys from pathlib import Path import numpy as np @@ -42,11 +44,33 @@ def smooth(gate, attack, release): return out +def spliced(score, length): + """The vertical short's bed: score sections joined just before their onsets.""" + source = load(SOURCES / score["file"], 2) + music = np.zeros((length, 2), np.float32) + fade = int(score["crossfade"] * RATE) + for source_from, source_to, at in score["segments"]: + piece = source[int(source_from * RATE):int(source_to * RATE) + fade].copy() + ramp = np.sin(np.linspace(0, np.pi / 2, fade))[:, None] + if at > 0: + piece[:fade] *= ramp + piece[-fade:] *= ramp[::-1] + start = int(at * RATE) + end = min(length, start + len(piece)) + music[start:end] += piece[:end - start] + return music + + def main(): - film = json.loads((HERE / "film.json").read_text()) + short = "--short" in sys.argv + film = json.loads((HERE / ("short.json" if short else "film.json")).read_text()) + name = "short-soundtrack" if short else "soundtrack" length = int(film["format"]["length"] * RATE) - music = load(SOURCES / film["score"]["file"], 2)[:length] - music = np.pad(music, ((0, length - len(music)), (0, 0))) + if short: + music = spliced(film["score"], length) + else: + music = load(SOURCES / film["score"]["file"], 2)[:length] + music = np.pad(music, ((0, length - len(music)), (0, 0))) # The score's own last chord decays fast; ease it out under the title. fade_from, fade_to = (int(second * RATE) for second in film["score"]["fade_out"]) music[fade_from:fade_to] *= np.cos(np.linspace(0, np.pi / 2, fade_to - fade_from))[:, None] ** 2 @@ -66,11 +90,11 @@ def main(): AUDIO.mkdir(parents=True, exist_ok=True) raw = AUDIO / "premix.f32" raw.write_bytes(mix.astype(np.float32).tobytes()) - wav = AUDIO / "soundtrack.wav" + wav = AUDIO / f"{name}.wav" subprocess.run(["ffmpeg", "-loglevel", "error", "-y", "-f", "f32le", "-ar", str(RATE), "-ac", "2", "-i", str(raw), "-af", "loudnorm=I=-14:TP=-1.5:LRA=11", "-ar", str(RATE), "-c:a", "pcm_s16le", str(wav)], check=True) subprocess.run(["ffmpeg", "-loglevel", "error", "-y", "-i", str(wav), "-c:a", "libmp3lame", "-b:a", "320k", - str(AUDIO / "soundtrack.mp3")], check=True) + str(AUDIO / f"{name}.mp3")], check=True) raw.unlink() print(wav) diff --git a/design/promo-film/score.py b/design/promo-film/score.py index 968a4ee6d..ad2a03938 100644 --- a/design/promo-film/score.py +++ b/design/promo-film/score.py @@ -24,13 +24,29 @@ PROMPT = ( ) +SHORT_PROMPT = ( + "Instrumental score for a premium 30-second vertical promo of a mindful-living app. No vocals. " + "Warm, hopeful and cinematic, 76 BPM, D major, same sound as a calm East Asian-tinged storybook film. " + "0-4 s: airy pads, a soft felt-piano motif and a small firefly chime. " + "4-10 s: gentle bamboo flute melody over piano with light guzheng plucks. " + "10-17 s: graceful guzheng and erhu phrase over a slow soft taiko heartbeat and warm low strings. " + "17-24 s: uplifting lift with warm strings and piano arpeggios. " + "24-30 s: resolve to a tender final chord with a sparkling chime and a clean natural ending. " + "Mixed spaciously so a narrator's voice sits clearly on top: no busy midrange, no loud drums." +) + + def main(): - takes = int(sys.argv[1]) if len(sys.argv) > 1 else 2 + short = "--short" in sys.argv + args = [arg for arg in sys.argv[1:] if not arg.startswith("--")] + takes = int(args[0]) if args else 2 + prompt = SHORT_PROMPT if short else PROMPT + prefix = "short-score" if short else "score" OUT.mkdir(parents=True, exist_ok=True) for take in range(1, takes + 1): body = {"model": "google/lyria-3-pro-preview", "modalities": ["text", "audio"], "audio": {"format": "mp3"}, "stream": True, - "messages": [{"role": "user", "content": PROMPT}]} + "messages": [{"role": "user", "content": prompt}]} request = urllib.request.Request("https://openrouter.ai/api/v1/chat/completions", data=json.dumps(body).encode(), headers={"Authorization": "Bearer " + key(), "Content-Type": "application/json"}) chunks = [] @@ -46,10 +62,10 @@ def main(): chunks.append(audio["data"]) if not chunks: sys.exit("Lyria returned no audio") - path = OUT / f"score-{take}.mp3" + path = OUT / f"{prefix}-{take}.mp3" path.write_bytes(b"".join(base64.b64decode(chunk) for chunk in chunks)) print(path) - (OUT / "score-prompt.txt").write_text(PROMPT + "\n") + (OUT / f"{prefix}-prompt.txt").write_text(prompt + "\n") if __name__ == "__main__": diff --git a/design/promo-film/short.json b/design/promo-film/short.json new file mode 100644 index 000000000..ac753ea73 --- /dev/null +++ b/design/promo-film/short.json @@ -0,0 +1,230 @@ +{ + "title": "Inner Breeze: a day with Lumi (vertical short)", + "format": { + "aspect": "9:16", + "length": 36.0, + "fps": 24 + }, + "score": { + "file": "score-1.mp3", + "duck_db": -7.0, + "crossfade": 0.08, + "fade_out": [ + 32.55, + 35.95 + ], + "segments": [ + [ + 0.0, + 12.7, + 0.0 + ], + [ + 29.9, + 37.4, + 12.7 + ], + [ + 41.5, + 47.0, + 20.2 + ], + [ + 53.1, + 56.5, + 25.7 + ], + [ + 58.15, + 65.0, + 29.1 + ] + ] + }, + "voices": [ + { + "take": "hello-2", + "at": 2.0 + }, + { + "take": "welcome-2", + "at": 6.8 + }, + { + "take": "taichi-2", + "at": 13.4 + }, + { + "take": "habits-2", + "at": 21.3 + }, + { + "take": "ask-2", + "at": 26.1 + }, + { + "take": "end-3", + "at": 29.75 + } + ], + "clips": [ + { + "clip": 1, + "start": 0.0, + "end": 6.6, + "keyframes": [ + [ + "shot-01", + 0.0 + ] + ] + }, + { + "clip": 2, + "start": 6.6, + "end": 8.6, + "keyframes": [ + [ + "shot-02", + 0.0 + ] + ] + }, + { + "clip": 3, + "start": 8.6, + "end": 10.6, + "keyframes": [ + [ + "shot-03", + 0.0 + ] + ] + }, + { + "clip": 4, + "start": 10.6, + "end": 12.7, + "keyframes": [ + [ + "shot-05", + 0.0 + ] + ] + }, + { + "clip": 5, + "start": 12.7, + "end": 16.6, + "keyframes": [ + [ + "shot-06", + 0.0 + ] + ] + }, + { + "clip": 6, + "start": 16.6, + "end": 20.2, + "keyframes": [ + [ + "shot-07", + 0.0 + ] + ] + }, + { + "clip": 7, + "start": 20.2, + "end": 25.7, + "keyframes": [ + [ + "shot-09", + 0.0 + ] + ] + }, + { + "clip": 8, + "start": 25.7, + "end": 29.1, + "keyframes": [ + [ + "shot-10", + 0.0 + ] + ] + }, + { + "clip": 9, + "start": 29.1, + "end": 36.0, + "keyframes": [ + [ + "shot-11", + 0.0 + ] + ] + } + ], + "inserts": [ + { + "screens": [ + [ + "01-apps", + 0.0 + ], + [ + "03-practice-home", + 1.7 + ], + [ + "04-sun-salutation", + 3.7 + ] + ], + "from": 6.9, + "to": 12.55, + "side": "bottom" + }, + { + "screens": [ + [ + "tai-chi-monk", + 0.0 + ], + [ + "tai-chi-woman", + 3.6 + ] + ], + "from": 13.0, + "to": 20.05, + "side": "bottom" + }, + { + "screens": [ + [ + "05-habits", + 0.0 + ] + ], + "from": 20.5, + "to": 25.55, + "side": "bottom" + }, + { + "screens": [ + [ + "02-lumi-customize", + 0.0 + ] + ], + "from": 26.0, + "to": 28.95, + "side": "bottom" + } + ], + "end_card": 29.6 +}