"""Print the Flow request for animating shots (Omni 1.1 Flash, first/last frame locked). python3 previz/vidreq.py S16 S17 # frames to attach, clip length, and the prompt Prefers upscaled frames in previz/keyframes_hd/, falls back to previz/keyframes/ (and flags an HD copy that is older than a later local edit). Shot-specific motion lives in previz/clips/prompts.py, written against the generated keyframes (never reused from an old storyboard): M = {"S16": (6, "Slow push-in; the singer leans into the mic on the downbeat, the crowd jumps on beat 3."), ...} COST = ... # anything from here on is ignored by this script Edit the constants below for the project: STYLE (the look and real-world production), LOCKS (identity locks for characters/puppets that video models like to morph — restate their build in words every time), MUSIC (tempo/feel). First/last-frame models ignore in-between frames: for shots with more than two keyframes, chain one clip per frame pair. """ import json, pathlib, re, sys STYLE = "Practical sets and puppets, real camera." LOCKS = "" # e.g. "The hand puppet stays a flat orange slab with square eyes on a puppeteer's arm; " MUSIC = "The music is upbeat: movements, bounces and hits land on the beat." ROOT = pathlib.Path(__file__).resolve().parent SHOTS = {s["id"]: s for s in json.load(open(ROOT / "shots.json"))} FRAMES = json.load(open(ROOT / "keyframes.json")) _ns, _p = {}, ROOT / "clips/prompts.py" if _p.exists(): exec(_p.read_text().split("COST =")[0], _ns) MOTION = _ns.get("M", {}) def scene_of(frame): """The frame's own scene text (without the shared style and character boilerplate).""" p = frame["prompt"] p = p[p.find("Scene:") + 6:] if "Scene:" in p else p p = p.split(" Character look:")[0].split(" Prop scale:")[0].strip() return re.sub(r"^(START|END|IN-BETWEEN) frame.*?(\)\. |: [^.]*\. )", "", p) def frame_file(fid): """The newest copy of a frame: an HD download only wins if the keyframe hasn't been edited since.""" found = [ROOT / d / f"{fid}.{ext}" for d in ("keyframes_hd", "keyframes") for ext in ("png", "jpg", "jpeg")] found = [p for p in found if p.exists()] if not found: return None hd = [p for p in found if p.parent.name == "keyframes_hd"] local = [p for p in found if p.parent.name == "keyframes"] if hd and local and max(p.stat().st_mtime for p in local) > max(p.stat().st_mtime for p in hd) + 60: return max(local, key=lambda p: p.stat().st_mtime) return (hd or local)[0] def clip_len(dur): """Omni 1.1 Flash lengths: 4/6/8/10 s; generate the shortest that covers the shot (trimmed in the edit).""" return next((n for n in (4, 6, 8, 10) if n >= dur), 10) for sid in sys.argv[1:]: shot = SHOTS[sid] frames = [f for f in FRAMES if f["shot"] == sid] files = [frame_file(f["id"]) for f in frames] move = frames[0].get("move") or "a gentle push-in" action = MOTION[sid][1] if sid in MOTION else " Then: ".join(scene_of(f) for f in (frames[0], frames[-1]) if f) chars = sorted({a for f in frames for a in f["attach"]}) first, last = files[0], (files[-1] if len(files) > 1 else None) mids = files[1:-1] print(f"{sid} {shot['t0']:.2f}-{shot['t1']:.2f}s ({shot['dur']:.2f}s) -> generate {clip_len(shot['dur'])} s") print(" FIRST FRAME:", first) if mids: print(" (in-between frames: chain one clip per pair, the model ignores middle frames:", ", ".join(str(m) for m in mids), ")") print(" LAST FRAME: ", last or "- (single keyframe: animate from the first frame only)") print(" CHARACTERS: ", "; ".join(chars) or "-") prompt = (f"Animate this live-action music-video shot with Omni 1.1 Flash, 720p, {clip_len(shot['dur'])} seconds, 16:9, " f"{'from the attached FIRST frame to the attached LAST frame' if last else 'starting exactly from the attached frame'}. " f"Camera and action: {move}. Story beat: {action} " "Keep every character, puppet, prop and set exactly as in the frame(s): same faces, costumes, shapes " f"{('(' + LOCKS.strip().rstrip(';') + ')') if LOCKS else ''}, no morphing, no new characters. {STYLE} {MUSIC} " "No dialogue, no text changes, no subtitles.") print(" PROMPT:", json.dumps(prompt))