""" Build the FULL composition for the complete Mem0_1 tutorial (~752s output). Source times -> output times using the segment list from build_cut.py. """ import json, re, sys from pathlib import Path TRANSCRIPT = Path(r"D:\PromptEngineer48\In-Progress\P11-Editor\edit\transcripts\Mem0_1.json") HF_DIR = Path(r"D:\PromptEngineer48\In-Progress\P11-Editor\edit\hf") SKILL = Path(r"C:\Users\palas\.claude\skills\screencast-hype") sys.path.insert(0, str(SKILL / "scripts")) from captions_html import build_captions # ---- same segment list as build_cut.py ---- THRESHOLD = 0.30 PAD = 0.08 FILLERS = {"uh", "um"} VIDEO_DUR = 805.5 data = json.load(open(TRANSCRIPT, encoding="utf-8")) words = [w for w in data["words"] if w.get("type") == "word"] clean = [w for w in words if w["text"].strip().lower().rstrip(",.") not in FILLERS] segs = [] s = e = None for w in clean: if s is None: s, e = w["start"], w["end"] elif w["start"] - e <= THRESHOLD: e = w["end"] else: segs.append((max(0, s - PAD), e + PAD)) s, e = w["start"], w["end"] if s is not None: segs.append((max(0, s - PAD), e + PAD)) clamped = [] for a, b in segs: a = round(max(0.0, a), 4) b = round(min(VIDEO_DUR, b), 4) if clamped and a < clamped[-1][1]: a = clamped[-1][1] if b > a: clamped.append((a, b)) segs = clamped def src_to_out(src_t): out_offset = 0.0 for (a, b) in segs: if src_t <= a: return out_offset if src_t <= b: return out_offset + (src_t - a) out_offset += (b - a) return out_offset # ---- full video duration ---- # Segment sum (~730s) is speech-only; actual base_cut.mp4 is 752.5s due to trailing content. # Use actual file duration for data-duration so the video plays to completion. TOTAL_DUR = 752.5 print(f"Total output duration: {TOTAL_DUR:.1f}s = {TOTAL_DUR/60:.1f}min") # ---- timing constants ---- T_TITLE_IN = 1.0 T_TITLE_OUT = 9.0 T_CHIP_IN = src_to_out(15.0) T_CHIP_OUT = T_CHIP_IN + 8.0 # ---- chapter section cards ---- # Output times calibrated from base_cut.mp4 spot-checks: # 95s: Mem0 slides ("THE FIX") 234s: file explorer / chapters ready # 305s: MCP JSON setup 362s: /mcp 11 tools visible # 410s: "ready to add memories" 478s: Jon Snow memory graph # 632s: Jon Snow answering 711s: dashboard / wrap-up CARD_DUR = 4.0 # (output_time, card_id, eyebrow_text, headline_html) sec_out = [ (95.0, "sec1", "UNIVERSAL MEMORY LAYER", "How It Works"), (234.0, "sec2", "MEM0.AI · FREE TIER", "Account
Setup"), (305.0, "sec3", "CLAUDE CODE MCP", "Wiring
Mem0 In"), (362.0, "sec4", "11 TOOLS AVAILABLE", "MCP
Connected"), (410.0, "sec5", "29 JON SNOW CHAPTERS", "Ingesting
Memories"), (478.0, "sec6", "GRAPH + VECTOR STORE", "Memories
Stored"), (632.0, "sec7", "THE MOMENT OF TRUTH", "Ask
Jon Snow"), (711.0, "sec8", "MEM0 + CLAUDE CODE", "Ship It
Anywhere"), ] print("\nChapter card output times:") for t_out, cid, eyebrow, _ in sec_out: print(f" {cid}: {t_out:.1f}s — {eyebrow}") # Sanity: warn if any two cards overlap for i in range(len(sec_out) - 1): t_end_i = sec_out[i][0] + CARD_DUR t_start_next = sec_out[i+1][0] if t_end_i > t_start_next: print(f" WARNING: {sec_out[i][1]} ends {t_end_i:.1f}s, {sec_out[i+1][1]} starts {t_start_next:.1f}s — overlap!") # ---- captions (full video) ---- raw_divs, raw_tweens = build_captions(words, start=0.0, end=VIDEO_DUR, per=2, map_time=src_to_out) def filter_tweens_title(tweens_str): """Suppress individual caption tweens that fire during the title card window only.""" lines = tweens_str.split("\n") out, skip = [], False for line in lines: m = re.search(r',(\d+\.\d+)\);$', line) t_val = float(m.group(1)) if m else None if t_val is not None and T_TITLE_IN <= t_val <= T_TITLE_OUT: skip = True continue if skip and "opacity:0" in line: skip = False continue skip = False out.append(line) return "\n".join(out) def inject_set_resets(tweens_str): """Inject tl.set('.cap',{opacity:0}) 1ms before every caption entry to prevent overlap.""" lines = tweens_str.split("\n ") result = [] for line in lines: if line.strip().startswith("tl.fromTo("): m = re.search(r',(\d+\.\d+)\);$', line) if m: t = float(m.group(1)) result.append(f'tl.set(".cap",{{opacity:0}},{max(t-0.001,0):.3f});') result.append(line) return "\n ".join(result) cap_tweens = inject_set_resets(filter_tweens_title(raw_tweens)) # ---- build section card HTML divs ---- sec_div_lines = [] for _, cid, eyebrow, headline in sec_out: sec_div_lines.append(f"""
{eyebrow}
{headline}
""") sec_divs = "\n".join(sec_div_lines) # ---- build section card GSAP tweens ---- sec_tween_lines = [] for t_in, cid, _, _ in sorted(sec_out, key=lambda x: x[0]): t_out = t_in + CARD_DUR sec_tween_lines += [ f' tl.set("#{cid}", {{ xPercent: -50, yPercent: -50 }}, 0);', f' tl.fromTo("#{cid}",', f' {{ opacity: 0, scale: 0.88, filter: "blur(10px)" }},', f' {{ opacity: 1, scale: 1, filter: "blur(0px)", duration: 0.4, ease: "power3.out" }},', f' {t_in:.2f});', f' tl.to("#{cid}", {{ opacity: 0, scale: 0.96, y: -14, duration: 0.3, ease: "power2.in" }}, {t_out:.2f});', ] sec_card_tweens = "\n".join(sec_tween_lines) # ---- cap-group blackout tweens for section cards ---- # Title card blackout is handled inline in main JS block. # For each section card: hide cap-group in, clear individual caps on restore, show cap-group out. cg_lines = [] for t_in, cid, _, _ in sec_out: t_out = t_in + CARD_DUR cg_lines += [ f' tl.to("#cap-group", {{ opacity: 0, duration: 0.05 }}, {t_in:.2f});', f' tl.set(".cap", {{ opacity: 0 }}, {t_out - 0.001:.3f});', f' tl.to("#cap-group", {{ opacity: 1, duration: 0.05 }}, {t_out:.2f});', ] cap_group_sec_tweens = "\n".join(cg_lines) # ---- SFX tracks for section card swooshes ---- # Tracks 0-5: bg video, voice, riser, impact, whoosh_intro, pop_chip # Tracks 6+: one per section card whoosh sfx_sec_lines = [] for i, (t_in, cid, _, _) in enumerate(sec_out): sfx_t = max(0.0, t_in - 0.15) sfx_sec_lines.append( f' ' ) sfx_sec_html = "\n".join(sfx_sec_lines) # ---- generate HTML ---- html = f"""
{sfx_sec_html}
Mem0 — Universal Memory Layer
Give Your AI Agent
Persistent Memory
56K+ GitHub Stars • Free Tier Available
{sec_divs}
WHY AGENTS FORGET  
The Problem
{raw_divs}
""" out = HF_DIR / "index.html" out.write_text(html, encoding="utf-8") print(f"\nWritten: {out}") print(f"Caption chunks: {raw_divs.count('