Open source CapCut alternative.
TypeScript
docs: cloud exports render in the browser
David Le9c922fad9a5c
diff --git a/docs/guides/cut/README.md b/docs/guides/cut/README.mdindex a4451e84..efae5c52 100644--- a/docs/guides/cut/README.md+++ b/docs/guides/cut/README.md@@ -40,7 +40,7 @@ A dropped file does not wait for that upload. Because a presign claims the storeStorage a subscription paid for outlives the subscription for a while: when Pro ends and the account still holds more than the free tier, it keeps everything for thirty days, warned in the editor and on the projects home. After that the daily sweep brings it back under the cap — least-recently-updated projects first, then the oldest library assets, stopping the moment it fits — so what survives is the recent work, and an account already under the cap is never touched.-A cloud project can be shared read-only, Google-Docs style: the editor's Share dialog invites specific emails (viewers sign in) or opens the link to anyone (no sign-in), and switches opt extra surfaces in — chat, media, AI generations, subtitles, details — on top of the always-shared preview and timeline. The share row's id is the link token, so revoking deletes the link. Viewers ride a third backend driver against `/api/cut-shared/<token>/*`, a deliberately public API surface (the one exception to session auth on the cloud side): the server resolves access per request, filters the doc to the shared surfaces before it leaves, and refuses media outside that filter, so hiding is enforced by the backend rather than the client. A public share's reads are cached at the edge for a lifetime that tracks how long the owner has been idle — a doc saved seconds ago is served near-live, one untouched for an hour is served from cache for minutes — and the same number is handed back as the viewer's poll interval, so a link a crowd opens costs a handful of origin requests rather than one per viewer per tick. A restricted share's reads depend on the viewer's session, so they are never cached. A shared project's media is served from Cloudflare's edge rather than presigned against R2's S3 endpoint, which nothing caches: a Worker holding a private bucket binding checks a short token the hosted API mints, then answers from cache keyed on the object alone. Dropping the token from the cache key is what makes the token affordable to keep short — every viewer and every re-mint share one cached copy — and a short token is what makes unsharing mean something, since a presigned URL is a bearer credential nothing can withdraw before it expires. Owner-side editing still presigns R2 directly, where the URLs are minted on fixed windows so a browser can reuse bytes across reloads. A shared link unfurls with the project's own card: the render worker derives a first-frame still and a five-second animation from the opening of the cut, the page's metadata points at them through a URL carrying the doc version, and a project with no card yet gets a drawn one. Viewers poll the doc version on an interval the server picks — shared views trail live edits, they don't stream them — and a "Copy project" action duplicates everything the share exposes — the filtered doc, its media, and the chat threads when chat is shared — server-side into the viewer's own account and quota. Copies queue rather than run in the request: each request writes a job row and publishes it to a Cloudflare Queue whose serial consumer executes one copy at a time, so a burst of copy requests can't stampede storage; the client polls the job for the outcome. An owner duplicating their own cloud project from the dashboard rides the same queue. Exports, hover-preview proxies, share cards, and URL imports run on the render worker — a pool of containers (`site/src/cut/worker/`) that claim job rows from Postgres, reuse the engine's exact ffmpeg pipeline against R2, and report progress back through the rows the client polls. Each replica takes one job at a time, so a render has the whole machine to itself, and the queue is claimed by what someone is watching first: an export or a URL import goes ahead of the background artwork. The artwork waits for a lull too — a project's hover proxy and share card rebuild when the editor closes or the tab goes to the background, so a session of editing spends the pool on the renders the user asked for. Transcription and mic dictation prefer this Mac: with the app running they use on-device speech even for a cloud project, and fall back to a hosted, credit-metered route — Gemini producing cue-level timestamps from browser-rendered audio, word timings interpolated inside each cue — when it isn't. That split between where a project's data lives and where its work runs is its own guide: [Local compute for cloud projects](local-compute.md). The assistant offers its Gemini models (which already run entirely in the page); the Claude/Codex CLI providers stay app-only because they are the user's local logins.+A cloud project can be shared read-only, Google-Docs style: the editor's Share dialog invites specific emails (viewers sign in) or opens the link to anyone (no sign-in), and switches opt extra surfaces in — chat, media, AI generations, subtitles, details — on top of the always-shared preview and timeline. The share row's id is the link token, so revoking deletes the link. Viewers ride a third backend driver against `/api/cut-shared/<token>/*`, a deliberately public API surface (the one exception to session auth on the cloud side): the server resolves access per request, filters the doc to the shared surfaces before it leaves, and refuses media outside that filter, so hiding is enforced by the backend rather than the client. A public share's reads are cached at the edge for a lifetime that tracks how long the owner has been idle — a doc saved seconds ago is served near-live, one untouched for an hour is served from cache for minutes — and the same number is handed back as the viewer's poll interval, so a link a crowd opens costs a handful of origin requests rather than one per viewer per tick. A restricted share's reads depend on the viewer's session, so they are never cached. A shared project's media is served from Cloudflare's edge rather than presigned against R2's S3 endpoint, which nothing caches: a Worker holding a private bucket binding checks a short token the hosted API mints, then answers from cache keyed on the object alone. Dropping the token from the cache key is what makes the token affordable to keep short — every viewer and every re-mint share one cached copy — and a short token is what makes unsharing mean something, since a presigned URL is a bearer credential nothing can withdraw before it expires. Owner-side editing still presigns R2 directly, where the URLs are minted on fixed windows so a browser can reuse bytes across reloads. A shared link unfurls with the project's own card: the render worker derives a first-frame still and a five-second animation from the opening of the cut, the page's metadata points at them through a URL carrying the doc version, and a project with no card yet gets a drawn one. Viewers poll the doc version on an interval the server picks — shared views trail live edits, they don't stream them — and a "Copy project" action duplicates everything the share exposes — the filtered doc, its media, and the chat threads when chat is shared — server-side into the viewer's own account and quota. Copies queue rather than run in the request: each request writes a job row and publishes it to a Cloudflare Queue whose serial consumer executes one copy at a time, so a burst of copy requests can't stampede storage; the client polls the job for the outcome. An owner duplicating their own cloud project from the dashboard rides the same queue. A cloud project's export renders in the browser. The tab already draws the whole cut for the preview, so it can draw it again frame by frame into an MP4 and upload the finished file — no round trip that pulls the media back out of storage into a container, no waiting behind someone else's render, and a file that matches the preview because the same compositor drew both. What the tab cannot hold — a long cut, a very large frame — still goes to the worker, and so does everything the editor renders on its own behalf: hover-preview proxies, share cards, streaming ladders, and URL imports. That worker is a pool of containers (`site/src/cut/worker/`) that claim job rows from Postgres, reuse the engine's exact ffmpeg pipeline against R2, and report progress back through the rows the client polls. Each replica takes one job at a time, so a render has the whole machine to itself, and the queue is claimed by what someone is watching first: an export or a URL import goes ahead of the background artwork. The artwork waits for a lull too — a project's hover proxy and share card rebuild when the editor closes or the tab goes to the background, so a session of editing spends the pool on the renders the user asked for. Transcription and mic dictation prefer this Mac: with the app running they use on-device speech even for a cloud project, and fall back to a hosted, credit-metered route — Gemini producing cue-level timestamps from browser-rendered audio, word timings interpolated inside each cue — when it isn't. That split between where a project's data lives and where its work runs is its own guide: [Local compute for cloud projects](local-compute.md). The assistant offers its Gemini models (which already run entirely in the page); the Claude/Codex CLI providers stay app-only because they are the user's local logins.A share link opened on a phone plays rather than edits. The editor composites a project live — a video decoder per clip, painted onto a canvas — which is the right design on a desktop and an impossible one on a phone, where the decoders alone exhaust what a tab is given. So below the width the editor needs, the share serves a player instead: the cut as a single adaptive stream with the platform's own controls, and whichever surfaces the share opted in — chat, media, subtitles, details — as sheets that rise over it. The desktop share is untouched. The choice is made in code rather than in styling, because hiding the editor with a class would still have mounted it and started every decode.diff --git a/docs/guides/cut/local-compute.md b/docs/guides/cut/local-compute.mdindex 2606d86d..0e3ecf9a 100644--- a/docs/guides/cut/local-compute.md+++ b/docs/guides/cut/local-compute.md@@ -37,7 +37,11 @@ Dictation is the same trade in the other direction: with the app running, mic au## Export-Export still runs hosted for cloud projects, on the render worker. Moving it to the Mac is the same shape as speech with two extra pieces: the engine has to pull each clip from a signed URL before it can render, and push the finished file back up to storage after.+A cloud project exports in the browser. The rule above still holds — the finished file is uploaded to the project's own storage and registered there, so where it lands is unchanged; what moved is who does the work, and the answer turned out to be the machine already in front of the user.++That works because the editor composites the cut live to draw the preview. Rendering is the same drawing done on a clock the tab steps rather than follows, so a browser and a container produce the same picture from the same document, and the browser needs nothing pulled out of storage that it is not already playing.++The worker is the rung above rather than the default: a cut too long or too large for a tab to hold goes there, as do the renders the editor fires on its own — hover proxies, share cards, streaming ladders. Moving export to the Mac would be a third path and there is no longer much to win from it.## Rules@@ -51,7 +55,8 @@ Export still runs hosted for cloud projects, on the render worker. Moving it to| Work | Runs | Why || --- | --- | --- || Transcription, dictation | the Mac when it is there, hosted otherwise | the app ships the speech tool |-| Export, encoding, thumbnails | the Mac for its own projects, hosted for cloud ones | see Export above |+| Export | the Mac for its own projects, the browser for cloud ones, the worker past what a tab holds | see Export above |+| Thumbnails, waveforms, media probing | the browser, always | it decodes the media itself || Image, video, and voice generation | hosted, always | no local counterpart || The assistant's Gemini models | hosted, always | credits and the user's session || The assistant's Claude and Codex providers | the Mac, always | the user's own CLI logins |