Skip to content

Open-source AI podcast clipper. Generate vertical clips with face tracking and burned-in captions. CLI, MCP server, web app.

Send a multicam edit to the podcli cloud editor, and render its cut here (#240)

Nika Siradze016c29365b4b
diff --git a/CLAUDE.md b/CLAUDE.md
index 0ed9397..a6332ba 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -61,7 +61,7 @@ All 27 tools registered by the MCP server.
| Tool | What it does |
|------|-------------|
-| `manage_multicam` | Map camera, mic and call-recording files to people, sync them by audio, auto-cut to the speaker, render, or export a studio shoot to Premiere / FCPXML |
+| `manage_multicam` | Map camera, mic and call-recording files to people, sync them by audio, auto-cut to the speaker, render, export a studio shoot to Premiere / FCPXML, or hand the edit to the podcli cloud editor |
**Content and configuration**
diff --git a/README.md b/README.md
index bb2a7b8..0dce7df 100644
--- a/README.md
+++ b/README.md
@@ -78,6 +78,7 @@ Clips land in `podcli-clips/` in the directory you ran it from, so each show kee
- Remote shows too: one file per person becomes a split screen, and a single gallery recording is split into a camera per tile. Questions stay on the split and the guest goes full frame on long answers
- Render the episode as an MP4 with one WAV per person. Studio shoots can also go to Premiere or Final Cut as a timeline that points at your original files
- Same edit from the studio (Multicam edit), the CLI (`podcli multicam <folder>`), or an agent (`manage_multicam`). Re-running reuses the sync and the cut, so only the step you changed runs again
+- With podcli Pro, steer the cut in the cloud editor: `podcli multicam <folder> --cloud` sends small previews and the transcript (your camera files stay on your computer), and `--pull` renders the cut you made there
**Finding the moments**
diff --git a/backend/cli.py b/backend/cli.py
index cbbaedb..9bc0e99 100644
--- a/backend/cli.py
+++ b/backend/cli.py
@@ -880,6 +880,9 @@ def _run_multicam(args, mc, target: str):
print(f" ✓ Deleted multicam edit {session.session_id}. Your recordings are untouched.")
return {"deleted": True, "session_id": session.session_id}
+ if args.pull:
+ return _pull_multicam(args, mc, target)
+
people = [n.strip() for n in (args.people or "").split(",") if n.strip()] or None
session = _open_multicam_session(target, people)
if args.state:
@@ -963,12 +966,16 @@ def _run_multicam(args, mc, target: str):
session = mc.build_preview(session, progress_callback=report)
done()
print(f" ✓ Preview proxies and mix in {os.path.dirname(session.preview['audio'])}")
- if not args.no_render:
- report, done = _multicam_progress("Rendering")
- outputs = mc.render_session(session, stems=not args.no_stems, progress_callback=report)
+ if args.cloud:
+ from services import multicam_cloud
+ report, done = _multicam_progress("Sending")
+ session = multicam_cloud.push(session, model_size=args.model, engine=args.engine, progress_callback=report)
done()
- for path in [outputs["video"], *(outputs.get("stems") or [])]:
- print(f" ✓ {path}")
+ print(f" ✓ Open the edit: {session.cloud['url']}")
+ print(f" Render it here when you're done: podcli multicam {session.session_id} --pull")
+ return session
+ if not args.no_render:
+ _render_multicam(args, mc, session)
print(f"\n Change anything and re-run: podcli multicam {session.session_id} [options]")
video = session.outputs.get("video")
if video and os.path.exists(video):
@@ -976,6 +983,33 @@ def _run_multicam(args, mc, target: str):
return session
+def _render_multicam(args, mc, session):
+ report, done = _multicam_progress("Rendering")
+ outputs = mc.render_session(session, stems=not args.no_stems, progress_callback=report)
+ done()
+ for path in [outputs["video"], *(outputs.get("stems") or [])]:
+ print(f" ✓ {path}")
+
+
+def _pull_multicam(args, mc, target: str):
+ """Renders the cut made in the podcli cloud editor from the camera files on this computer."""
+ from services import multicam_cloud
+
+ session = multicam_cloud.pull(multicam_cloud.resolve(target))
+ stats = mc.cut_stats(session)
+ removed = sum(r["end"] - r["start"] for r in session.removals)
+ print(f" Pulled the cloud edit: {stats['shots']} shots over {_fmt_time(stats['duration'])}"
+ + (f", {_fmt_time(removed)} cut out" if removed else ""))
+ for fmt in (["premiere", "fcpxml"] if args.export == "all" else [args.export] if args.export else []):
+ try:
+ print(f" ✓ {mc.export_xml(session, fmt)}")
+ except ValueError as e:
+ print(f" ! Skipped the {fmt} export: {e}", file=sys.stderr)
+ if not args.no_render:
+ _render_multicam(args, mc, session)
+ return session
+
+
def cmd_process(args):
"""Full auto pipeline: transcribe → suggest → export."""
from services.clip_generator import generate_clip
@@ -4963,6 +4997,10 @@ def main():
mc_p.add_argument("--engine", choices=["whisper-py", "whispercpp", "assemblyai"],
help="Transcription engine for --transcript (default: the one podcli is set up with)")
mc_p.add_argument("--activity", action="store_true", help="Report who speaks when (talk time, or spans with --json)")
+ mc_p.add_argument("--cloud", action="store_true",
+ help="Send the edit to the podcli cloud editor (Pro). Only previews go up; camera files stay here")
+ mc_p.add_argument("--pull", action="store_true",
+ help="Render the cut made in the podcli cloud editor. Target is this edit's session id or cloud id")
mc_p.add_argument("--json", action="store_true",
help="Print the edit as one JSON object on stdout; progress and messages go to stderr")
diff --git a/backend/main.py b/backend/main.py
index ee36b5a..0fcb9ba 100644
--- a/backend/main.py
+++ b/backend/main.py
@@ -1038,6 +1038,13 @@ def handle_manage_multicam(task_id: str, params: dict):
mc.render_session(session, stems=stems, progress_callback=progress("rendering"))
elif action == "export":
data["export_path"] = mc.export_xml(session, params.get("format", "premiere"))
+ elif action == "cloud":
+ from services import multicam_cloud
+ session = multicam_cloud.push(session, progress_callback=progress("sending"))
+ elif action == "pull":
+ from services import multicam_cloud
+ session = multicam_cloud.pull(session)
+ mc.render_session(session, stems=True, progress_callback=progress("rendering"))
else:
raise ValueError(f"Unknown multicam action {action!r}")
emit_result(task_id, "success", data={**mc.payload(session), **data})
diff --git a/backend/services/multicam.py b/backend/services/multicam.py
index a15f21e..262e649 100644
--- a/backend/services/multicam.py
+++ b/backend/services/multicam.py
@@ -164,6 +164,7 @@ class MulticamSession:
skipped: list[str] = field(default_factory=list)
preview: dict = field(default_factory=dict)
removals: list[dict] = field(default_factory=list)
+ cloud: dict = field(default_factory=dict) # {"id", "url"} once sent to the podcli cloud editor
def path(self) -> Path:
return _sessions_dir() / f"{self.session_id}.json"
diff --git a/backend/services/multicam_cloud.py b/backend/services/multicam_cloud.py
new file mode 100644
index 0000000..422ce20
--- /dev/null
+++ b/backend/services/multicam_cloud.py
@@ -0,0 +1,152 @@
+"""Hybrid multicam: prepare and render here, steer the cut in the podcli cloud editor.
+
+The camera files never leave this machine. Only what the browser editor plays
+goes up: a small proxy per camera, the mic mix, a still per camera, the
+transcript and the edit itself. About 550 MB for a two-hour, three-camera
+episode, where the originals would be about 20 GB.
+"""
+
+from __future__ import annotations
+
+import json
+import os
+import re
+import tempfile
+import urllib.error
+import urllib.parse
+import urllib.request
+from typing import Callable, Optional
+
+from services import multicam as mc
+from services import podcli_cloud
+
+ProgressCallback = Optional[Callable[[float, str], None]]
+
+CONTENT_TYPES = {".mp4": "video/mp4", ".m4a": "audio/mp4", ".jpg": "image/jpeg", ".json": "application/json"}
+
+
+class MulticamCloudError(RuntimeError):
+ pass
+
+
+def editor_url(edit_id: str) -> str:
+ """Where the edit opens in a browser: the app sits beside the API, at /app."""
+ override = os.environ.get("PODCLI_APP_URL", "").rstrip("/")
+ if override:
+ return f"{override}/multicam/{edit_id}"
+ api = urllib.parse.urlparse(podcli_cloud.api_url())
+ host = api.netloc[4:] if api.netloc.startswith("api.") else api.netloc
+ return f"{api.scheme}://{host}/app/multicam/{edit_id}"
+
+
+def _emit(cb: ProgressCallback, pct: float, msg: str) -> None:
+ if cb:
+ cb(pct, msg)
+
+
+def _put(url: str, path: str) -> int:
+ size = os.path.getsize(path)
+ ctype = CONTENT_TYPES.get(os.path.splitext(path)[1].lower(), "application/octet-stream")
+ with open(path, "rb") as fh:
+ req = urllib.request.Request(url, data=fh, method="PUT",
+ headers={"content-type": ctype, "content-length": str(size)})
+ try:
+ with urllib.request.urlopen(req, timeout=3600):
+ pass
+ except urllib.error.HTTPError as exc:
+ raise MulticamCloudError(f"upload of {os.path.basename(path)} failed: HTTP {exc.code}") from None
+ except urllib.error.URLError as exc:
+ raise MulticamCloudError(f"upload of {os.path.basename(path)} failed: {exc.reason}") from None
+ return size
+
+
+def _request(method: str, path: str, body: Optional[dict] = None) -> dict:
+ try:
+ return podcli_cloud.request(method, path, body, timeout=120) or {}
+ except podcli_cloud.CloudError as exc:
+ raise MulticamCloudError(str(exc)) from None
+
+
+def push(session: mc.MulticamSession, *, model_size: str = "base", engine: Optional[str] = None,
+ progress_callback: ProgressCallback = None) -> mc.MulticamSession:
+ """Builds what the editor plays, sends it, and remembers which cloud edit this session became."""
+ if not podcli_cloud.signed_in():
+ raise MulticamCloudError("not signed in to podcli cloud. Run `podcli login` first")
+ if not session.cuts:
+ raise MulticamCloudError("plan the cut before sending the edit")
+
+ _emit(progress_callback, 5, "Writing the transcript")
+ words = mc.transcript(session, model_size=model_size, engine=engine)["words"]
+ _emit(progress_callback, 35, "Making previews")
+ session = mc.build_preview(session)
+ activity = mc.activity(session)
+ data = mc.payload(session)
+ preview = data.pop("preview", None) or {}
+ for key in ("outputs", "stats"):
+ data.pop(key, None)
+ if not preview.get("audio"):
+ raise MulticamCloudError("the preview mix wasn't built")
+
+ with tempfile.TemporaryDirectory(prefix="podcli_cloud_") as tmp:
+ transcript = os.path.join(tmp, "transcript.json")
+ with open(transcript, "w", encoding="utf-8") as f:
+ json.dump({"words": words}, f)
+ files = {"audio": preview["audio"], "transcript": transcript}
+ files.update({f"proxy:{k}": v for k, v in (preview.get("proxies") or {}).items()})
+ files.update({f"still:{k}": v for k, v in (preview.get("stills") or {}).items()})
+
+ opened = _request("POST", "/v1/multicam/hybrid", {
+ "name": session.name,
+ "engine": data,
+ "activity": activity,
+ "files": [{"name": n, "sizeBytes": max(1, os.path.getsize(p))} for n, p in files.items()],
+ })
+ stored = []
+ total = len(opened.get("uploads", [])) or 1
+ for i, slot in enumerate(opened.get("uploads", [])):
+ _emit(progress_callback, 60 + 35 * i / total, f"Uploading {slot['name'].split(':')[0]}")
+ size = _put(slot["uploadUrl"], files[slot["name"]])
+ stored.append({"name": slot["name"], "storageKey": slot["storageKey"], "sizeBytes": size})
+
+ _request("POST", f"/v1/multicam/{opened['id']}/hybrid-complete", {"files": stored})
+ latest = mc.MulticamSession.load(session.session_id)
+ latest.cloud = {"id": opened["id"], "url": editor_url(opened["id"])}
+ latest.save()
+ _emit(progress_callback, 100, "In the cloud editor")
+ return latest
+
+
+def resolve(target: str) -> mc.MulticamSession:
+ """A local session id, or the cloud edit id a local session was sent as."""
+ if re.fullmatch(r"[a-f0-9]{6,32}", target or ""):
+ return mc.MulticamSession.load(target)
+ for item in mc.list_sessions():
+ session = mc.MulticamSession.load(item["session_id"])
+ if (session.cloud or {}).get("id") == target:
+ return session
+ raise MulticamCloudError(
+ f"No multicam edit on this computer was sent to the cloud as {target}. "
+ "Pull it where it was prepared, with the camera files")
+
+
+def pull(session: mc.MulticamSession) -> mc.MulticamSession:
+ """Applies the cloud editor's cut, removals, look and names to this session, ready to render."""
+ edit_id = (session.cloud or {}).get("id")
+ if not edit_id:
+ raise MulticamCloudError("this edit was never sent to podcli cloud. Send it with --cloud first")
+ edit = _request("GET", f"/v1/multicam/{edit_id}/edit")
+ state = edit.get("state") or {}
+
+ names = {p.get("id"): p.get("name") for p in state.get("people", [])}
+ if any(names.get(p.id) and names[p.id] != p.name for p in session.people):
+ session = mc.update_mapping(session, {"people": [
+ {"id": p.id, "name": names.get(p.id) or p.name, "role": p.role} for p in session.people
+ ]})
+ if edit.get("look"):
+ session = mc.update_mapping(session, {"look": edit["look"]})
+ cuts = edit.get("cuts") or state.get("cuts")
+ if cuts:
+ session = mc.set_cuts(session, cuts)
+ if isinstance(edit.get("removals"), list):
+ session = mc.set_removals(session, [{"start": r["start"], "end": r["end"]} for r in edit["removals"]])
+ return session
diff --git a/backend/services/podcli_cloud.py b/backend/services/podcli_cloud.py
index 1c42b97..5317713 100644
--- a/backend/services/podcli_cloud.py
+++ b/backend/services/podcli_cloud.py
@@ -186,7 +186,8 @@ def _describe(exc: urllib.error.HTTPError) -> tuple[str, bool]:
if exc.code == 401:
return ("podcli Pro session expired — run `podcli login` again", False)
if exc.code == 402:
- return ("this workspace has no active podcli Pro subscription", False)
+ # A plan's own limits (footage, cameras) say which one; a bare 402 means no plan at all.
+ return (detail or "this workspace has no active podcli Pro subscription", False)
if exc.code == 403:
return (detail or "your role does not allow this", False)
if exc.code == 429:
diff --git a/src/server.ts b/src/server.ts
index 2999239..fc7b41c 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -2235,10 +2235,12 @@ export function createServer(): McpServer {
"Other actions: 'list', 'cut' (index, source_id: swap one shot's camera), 'set_cuts' (cuts: replace the whole cut with back-to-back shots), " +
"'activity' (who speaks when, as spans per person), 'previews' (still frames per camera, looks: true adds color-look stills), " +
"'preview' (background job: playback proxies, a mic mix and stills, for a browser editor such as podcli cloud), 'delete'. " +
+ "'cloud' (background job, needs podcli login and Pro: sends previews and the edit to the podcli cloud editor; camera files stay here) and " +
+ "'pull' (background job: renders the cut made in that editor from the files here). " +
"Call recordings work too: one file per person becomes a split screen, one gallery recording is split into a camera per tile; Premiere and FCPXML export refuse those layouts for now.",
{
action: z
- .enum(["new", "list", "show", "map", "sync", "plan", "cut", "set_cuts", "activity", "previews", "preview", "render", "export", "delete"])
+ .enum(["new", "list", "show", "map", "sync", "plan", "cut", "set_cuts", "activity", "previews", "preview", "render", "export", "cloud", "pull", "delete"])
.describe("What to do"),
session_id: z.string().optional().describe("Session id returned by 'new' (every action except new/list)"),
folder: z.string().optional().describe("For 'new': folder holding one episode's recordings, scanned recursively"),
diff --git a/src/ui/client/multicam-cloud.tsx b/src/ui/client/multicam-cloud.tsx
new file mode 100644
index 0000000..309619e
--- /dev/null
+++ b/src/ui/client/multicam-cloud.tsx
@@ -0,0 +1,51 @@
+import React, { useEffect, useState } from "react";
+import type { McSession } from "./multicam-types";
+
+/** The studio cuts automatically; this hands the edit to the podcli cloud editor and renders what comes back. */
+export default function MulticamCloud({
+ session,
+ locked,
+ onSend,
+ onPull,
+}: {
+ session: McSession;
+ locked: boolean;
+ onSend: () => void;
+ onPull: () => void;
+}) {
+ const [signedIn, setSignedIn] = useState(false);
+
+ useEffect(() => {
+ fetch("/api/pro/account")
+ .then((r) => r.json())
+ .then((a: { signedIn?: boolean }) => setSignedIn(Boolean(a.signedIn)))
+ .catch(() => setSignedIn(false));
+ }, []);
+
+ if (!signedIn) return null;
+ const sent = session.cloud?.url;
+
+ return (
+ <div className="section card">
+ <div className="card-title" style={{ marginBottom: 4 }}>Steer the cut in podcli cloud</div>
+ <p className="card-desc">
+ {sent
+ ? "Edit the cut and trim the conversation in the browser, then render it here from your camera files."
+ : "Sends small previews and the transcript, never your camera files. Then edit the cut and trim the conversation in the browser."}
+ </p>
+ <div style={{ display: "flex", gap: 8, flexWrap: "wrap" }}>
+ {sent && (
+ <a className="btn btn-primary btn-sm" href={sent} target="_blank" rel="noreferrer" style={{ textDecoration: "none" }}>
+ Open the cloud edit
+ </a>
+ )}
+ {sent && (
+ <button className="btn btn-ghost btn-sm" disabled={locked} onClick={onPull}>Render the cloud edit</button>
+ )}
+ <button className={`btn ${sent ? "btn-ghost" : "btn-primary"} btn-sm`} disabled={locked} onClick={onSend}>
+ {sent ? "Send it again" : "Edit in podcli cloud"}
+ </button>
+ </div>
+ </div>
+ );
+}
diff --git a/src/ui/client/multicam-page.tsx b/src/ui/client/multicam-page.tsx
index 57aacc0..d38a4c7 100644
--- a/src/ui/client/multicam-page.tsx
+++ b/src/ui/client/multicam-page.tsx
@@ -9,6 +9,7 @@ import MulticamSources from "./multicam-sources";
import MulticamSync from "./multicam-sync";
import MulticamSummary from "./multicam-summary";
import MulticamResults, { DeliverActions } from "./multicam-deliver";
+import MulticamCloud from "./multicam-cloud";
import type { McJobKind, McPreviewsResp, McSession, McSessionSummary } from "./multicam-types";
const JOB_LABEL: Record<McJobKind, string> = {
@@ -16,6 +17,8 @@ const JOB_LABEL: Record<McJobKind, string> = {
plan: "Cutting",
render: "Rendering",
preview: "Preparing previews",
+ cloud: "Sending to podcli cloud",
+ pull: "Rendering the cloud edit",
};
const errorText = (e: unknown) => (e instanceof Error ? e.message : String(e));
@@ -233,6 +236,7 @@ export default function MulticamPage() {
{cutReady && (
<>
<MulticamSummary session={session} locked={locked} onEdit={mutate} onRecut={(extra) => startJob("plan", extra)} />
+ <MulticamCloud session={session} locked={locked} onSend={() => startJob("cloud")} onPull={() => startJob("pull")} />
<MulticamResults session={session} locked={locked} onMakeClips={onMakeClips} />
</>
)}
diff --git a/src/ui/client/multicam-types.ts b/src/ui/client/multicam-types.ts
index 94b6f64..cfaa5e1 100644
--- a/src/ui/client/multicam-types.ts
+++ b/src/ui/client/multicam-types.ts
@@ -95,6 +95,7 @@ export interface McSession {
resolved_style: "studio" | "remote";
auto_style: "studio" | "remote";
removals: { start: number; end: number; reason?: string }[];
+ cloud?: { id?: string; url?: string };
cuts: McCut[];
stats: McStats;
speaker_map: Record<string, string>;
@@ -123,7 +124,7 @@ export interface McPreviewsResp extends McSession {
previews: McPreviews;
}
-export type McJobKind = "sync" | "plan" | "render" | "preview";
+export type McJobKind = "sync" | "plan" | "render" | "preview" | "cloud" | "pull";
export const mcImageUrl = (path: string) => `/api/multicam/image?path=${encodeURIComponent(path)}`;
export const mcFileUrl = (path: string) => `/api/multicam/file?path=${encodeURIComponent(path)}`;
diff --git a/src/ui/public/css/styles.css b/src/ui/public/css/styles.css
index 1461ca2..e730e57 100644
--- a/src/ui/public/css/styles.css
+++ b/src/ui/public/css/styles.css
@@ -29,7 +29,7 @@
--blue-border: rgba(96, 165, 250, 0.22);
--yellow: #facc15;
--amber: #fbbf24;
- --amber-subtle: rgba(251, 191, 36, 0.12);
+ --amber-subtle: rgba(251, 191, 36, 0.09);
--glass-bg: rgba(22, 21, 15, 0.6);
--glass-border: rgba(255, 255, 255, 0.07);
--glass-hi: rgba(255, 255, 255, 0.06);
diff --git a/src/ui/web-server.ts b/src/ui/web-server.ts
index 335a173..7e49b7e 100644
--- a/src/ui/web-server.ts
+++ b/src/ui/web-server.ts
@@ -2243,7 +2243,7 @@ app.get("/api/reel-download", (req, res) => {
});
// --- Multicam: map sources, sync, cut, render one recording ---
-const MULTICAM_JOB_ACTIONS = new Set(["sync", "plan", "render", "preview"]);
+const MULTICAM_JOB_ACTIONS = new Set(["sync", "plan", "render", "preview", "cloud", "pull"]);
// activity saves the session when it refreshes its cache, so it waits for jobs like any write.
const MULTICAM_WRITE_ACTIONS = new Set(["map", "cut", "set_cuts", "export", "delete", "activity", ...MULTICAM_JOB_ACTIONS]);
const multicamPreviewDir = join(paths.working, "multicam");
diff --git a/tests/test_multicam_cloud.py b/tests/test_multicam_cloud.py
new file mode 100644
index 0000000..aed1511
--- /dev/null
+++ b/tests/test_multicam_cloud.py
@@ -0,0 +1,135 @@
+import json
+import shutil
+import sys
+import threading
+from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
+from pathlib import Path
+
+import pytest
+
+sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "backend"))
+
+from config.paths import paths # noqa: E402
+from services import multicam as mc # noqa: E402
+from services import multicam_cloud, podcli_cloud # noqa: E402
+
+import test_multicam # noqa: E402
+
+# Shared with the engine tests: a sandboxed home, and a two-camera episode.
+sandbox = test_multicam.sandbox
+episode = test_multicam.episode
+run_cli = test_multicam.run_cli
+
+
+class FakeCloud(BaseHTTPRequestHandler):
+ """The four routes hybrid mode uses, and storage that keeps what was PUT."""
+
+ state: dict = {}
+
+ def log_message(self, *args):
+ pass
+
+ def _json(self, code, body):
+ data = json.dumps(body).encode()
+ self.send_response(code)
+ self.send_header("content-type", "application/json")
+ self.send_header("content-length", str(len(data)))
+ self.end_headers()
+ self.wfile.write(data)
+
+ def _body(self):
+ return self.rfile.read(int(self.headers.get("content-length") or 0))
+
+ def do_POST(self):
+ s = self.state
+ assert self.headers["authorization"] == "Bearer test-token"
+ body = json.loads(self._body() or b"{}")
+ if self.path == "/v1/multicam/hybrid":
+ s["opened"] = body
+ uploads = [{"name": f["name"], "storageKey": f"k/{f['name']}",
+ "uploadUrl": f"{s['base']}/store/{f['name'].replace(':', '_')}"} for f in body["files"]]
+ return self._json(201, {"id": "11111111-2222-3333-4444-555555555555", "uploads": uploads})
+ if self.path.endswith("/hybrid-complete"):
+ s["completed"] = body
+ return self._json(200, {"status": "ready"})
+ self._json(404, {"error": "not found"})
+
+ def do_PUT(self):
+ self.state.setdefault("stored", {})[self.path] = len(self._body())
+ self.send_response(200)
+ self.end_headers()
+
+ def do_GET(self):
+ if self.path.endswith("/edit"):
+ return self._json(200, self.state["edit"])
+ self._json(404, {"error": "not found"})
+
+
+def cloud(sandbox, monkeypatch):
+ server = ThreadingHTTPServer(("127.0.0.1", 0), FakeCloud)
+ base = f"http://127.0.0.1:{server.server_address[1]}"
+ FakeCloud.state = {"base": base}
+ threading.Thread(target=server.serve_forever, daemon=True).start()
+ monkeypatch.setenv("PODCLI_API_URL", base)
+ monkeypatch.setitem(paths, "home", str(sandbox / "home"))
+ Path(paths["home"]).mkdir(parents=True, exist_ok=True)
+ podcli_cloud.write_token("test-token")
+ yield FakeCloud.state
+ server.shutdown()
+
+
+def test_editor_url_sits_beside_the_api(monkeypatch):
+ monkeypatch.setenv("PODCLI_API_URL", "https://api.podcli.com")
+ assert multicam_cloud.editor_url("abc") == "https://podcli.com/app/multicam/abc"
+ monkeypatch.setenv("PODCLI_APP_URL", "http://localhost:5173/app")
+ assert multicam_cloud.editor_url("abc") == "http://localhost:5173/app/multicam/abc"
+
+
[email protected](not shutil.which("ffmpeg"), reason="ffmpeg not installed")
+def test_sends_only_previews_and_renders_the_cloud_cut_here(episode, cloud, monkeypatch, capsys):
+ words = [{"start": 1.0, "end": 1.4, "text": "Hello", "person": "nika"}]
+ monkeypatch.setattr(mc, "transcript", lambda *a, **k: {"words": words})
+ code = run_cli(monkeypatch, str(episode), "--people", "Nika, Ana", "--set", "cam_one=camera:nika",
+ "--set", "cam_two=camera:ana", "--cloud", "-y")
+ out = capsys.readouterr().out
+ assert code == 0, out
+ assert "/app/multicam/11111111-2222-3333-4444-555555555555" in out
+
+ sent = cloud["opened"]
+ names = sorted(f["name"].split(":")[0] for f in sent["files"])
+ assert names == ["audio", "proxy", "proxy", "still", "still", "transcript"]
+ assert sent["engine"]["cuts"] and "preview" not in sent["engine"]
+ assert set(sent["activity"]["people"]) == {"nika", "ana"}
+ assert len(cloud["stored"]) == 6 and all(size > 0 for size in cloud["stored"].values())
+ sizes = {f["name"]: f["sizeBytes"] for f in cloud["completed"]["files"]}
+ camera_bytes = sum((episode / f"cam_{n}.mp4").stat().st_size for n in ("one", "two"))
+ assert sizes["transcript"] < 1000 and sum(sizes.values()) < 4 * camera_bytes
+
+ session = mc.MulticamSession.load(mc.list_sessions()[0]["session_id"])
+ assert session.cloud["id"] == "11111111-2222-3333-4444-555555555555"
+ assert not session.outputs.get("video")
+
+ one = next(s.id for s in session.sources if s.path.endswith("cam_one.mp4"))
+ end = sent["engine"]["cuts"][-1]["end"]
+ start = sent["engine"]["cuts"][0]["start"]
+ cloud["edit"] = {
+ "state": {**sent["engine"], "people": [{"id": "nika", "name": "Nika"}, {"id": "ana", "name": "Ana Smith"}]},
+ "cuts": [{"start": start, "end": end, "source_id": one}],
+ "removals": [{"start": 10, "end": 12}],
+ "look": "warm",
+ "revision": 4,
+ }
+ code = run_cli(monkeypatch, "11111111-2222-3333-4444-555555555555", "--pull", "--no-stems")
+ out = capsys.readouterr().out
+ assert code == 0, out
+ assert "Pulled the cloud edit: 1 shots" in out
+ session = mc.MulticamSession.load(session.session_id)
+ assert [p.name for p in session.people] == ["Nika", "Ana Smith"]
+ assert session.look == "warm" and session.removals == [{"start": 10.0, "end": 12.0}]
+ assert session.outputs["duration"] == pytest.approx(end - start - 2, abs=0.05)
+
+
+def test_pull_needs_an_edit_that_was_sent(sandbox):
+ with pytest.raises(multicam_cloud.MulticamCloudError, match="No multicam edit on this computer"):
+ multicam_cloud.resolve("11111111-2222-3333-4444-555555555555")