framefields-cloud

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

framefields-cloud

framefields-cloud

The cloud renders the pushed commit of a project on framefields' GPUs and can split a long film across several. Local rendering, checks and named renders in
framefields.json
are in
framefields-render
; project setup is in
framefields
.
云端使用 framefields 的 GPU 渲染项目中已 push 的 commit,并可将长影片拆分到多个 GPU 上渲染。本地渲染、检查以及
framefields.json
中的 named render 位于
framefields-render
;项目设置位于
framefields
。

Make the project render-ready

让项目达到可渲染状态

The worker clones the repo, installs from the lockfile, fetches assets and calls the render's export. So:
  • Commit and push first. Uncommitted changes aren't rendered (the CLI warns); a commit not on the remote, a folder outside git, or a repo without a remote is refused.
  • Commit the lockfile and pin
    packageManager
    . The worker renders with the project's own framefields version (2.11+ for split renders, 2.12+ for named renders). bun lockfiles can't be installed by the worker.
  • Every input must reach the worker: pinned with
    framefields assets add
    (preferred), tracked in Git LFS and pushed, or committed. Other
    .gitignore
    d files don't exist there.
  • Build asset paths from
    import.meta.url
    , never
    process.cwd()
    . Nothing may write into
    node_modules
    while rendering.
  • Builders stay pure: no rendering, generation or writes while building.
    npx framefields check <name>
    runs the same import locally; run it before every cloud render.
  • Private repos: the user connects GitHub once at https://framefields.dev/dashboard/settings#connections (the framefields GitHub App, ideally on all repositories). Public repos need nothing.
  • Key: it bills the account behind
    FRAMEFIELDS_API_KEY
    (https://framefields.dev/dashboard/keys), the same key as the AI gateway. Ask the user to set it in the environment; never print, write or embed it.
Pinned assets: the CLI and
renderCloud
upload any the bucket lacks and sign reads for remotes without a
publicUrl
(24 h; keys stay local). Workers download and cache them by hash; R2 downloads are free, unlike LFS bandwidth. Dashboard renders have nobody to sign, so they only read remotes with a
publicUrl
.
Worker 会 clone repo、根据 lockfile 安装依赖、获取 assets,并调用 render 的 export。因此:
  • 先 commit 并 push。 未 commit 的更改不会被渲染(CLI 会发出警告);如果 commit 不在 remote 上、文件夹不在 git 仓库中,或 repo 没有 remote,则会被拒绝。
  • 将 lockfile 纳入 commit,并固定
    packageManager
    。
    Worker 使用项目自身的 framefields 版本进行渲染(拆分渲染需 2.11+,named render 需 2.12+)。Worker 无法安装 bun lockfile。
  • 每个输入都必须能到达 Worker: 使用
    framefields assets add
    固定(推荐)、通过 Git LFS 跟踪并 push,或直接 commit 到 Git 中。其他被
    .gitignore
    忽略的文件在那里不存在。
  • 使用
    import.meta.url
    构建 asset 路径,绝不要使用
    process.cwd()
    。渲染期间不得向
    node_modules
    写入任何内容。
  • Builder 应保持纯粹: 构建期间不得执行渲染、生成或写入操作。
    npx framefields check <name>
    会在本地运行相同的 import;每次云端渲染前都应运行该命令。
  • 私有 repo: 用户只需在 https://framefields.dev/dashboard/settings#connections 连接一次 GitHub(使用 framefields GitHub App,最好授予其访问所有 repositories 的权限)。公共 repo 无需任何设置。
  • API key: 它会对
    FRAMEFIELDS_API_KEY
    (https://framefields.dev/dashboard/keys)所属的账户计费,与 AI gateway 使用同一个 key。应要求用户将其设置在环境变量中;切勿打印、写入或嵌入该密钥。
固定 assets:CLI 和
renderCloud
会上传 bucket 中缺少的任何 assets,并为没有
publicUrl
的 remotes 签名读取请求(有效期 24 小时;密钥保留在本地)。Worker 按 hash 下载并缓存这些 assets;R2 下载免费,而 LFS 流量收费。通过 dashboard 发起渲染时没有可用于签名的身份,因此只能读取带有
publicUrl
的 remotes。

CLI

CLI

Run from the project folder (where
framefields.json
and
package.json
are; in a monorepo that folder is sent as the workdir).
bash
npx framefields render film --cloud --plan   # workers, time, estimated cost; renders nothing
npx framefields render film --cloud          # render, then download to the render's output
npx framefields render --cloud               # the only named render
npx framefields render src/film.ts --cloud --export buildFilm --workers auto   # a module, no manifest
  • Flags override the named render's fields:
    --workers <n|auto>
    ,
    --max-workers <n>
    ,
    --codec h264|vp9
    ,
    --quality
    ,
    --select
    ,
    --output
    ,
    --export
    ,
    --json
    (final status as JSON).
  • --workers
    defaults to the render's
    workers
    , else 1.
    auto
    measures frame cost on one worker, then adds workers only while they stay efficient: a 5-minute film stays on one, a 3-hour film spreads to
    --max-workers
    (API cap 10).
  • Show the user
    --plan
    before a long or expensive render.
    It prints e.g.
    Plan: 4 workers, 1 h 50 min of render work, ready in about 35 min, estimated $1.20.
  • Output is one line per phase (
    probing
    , rendering N chunks and the audio,
    stitching
    ,
    Done in …: <file>, <GPU seconds>, <cost>.
    ), with progress and cost so far at most every 10 s. Run it in the background and let it finish; Ctrl-C cancels (used GPU time is charged).
在项目文件夹中运行(即包含
framefields.json
和
package.json
的目录;在 monorepo 中,会将该文件夹作为 workdir 发送)。
bash
npx framefields render film --cloud --plan   # workers, time, estimated cost; renders nothing
npx framefields render film --cloud          # render, then download to the render's output
npx framefields render --cloud               # the only named render
npx framefields render src/film.ts --cloud --export buildFilm --workers auto   # a module, no manifest
  • 以下 flags 会覆盖 named render 的对应字段:
    --workers <n|auto>
    、
    --max-workers <n>
    、
    --codec h264|vp9
    、
    --quality
    、
    --select
    、
    --output
    、
    --export
    、
    --json
    (以 JSON 格式返回最终状态)。
  • --workers
    默认为 render 的
    workers
    ,否则为 1。
    auto
    会先在一个 Worker 上测量帧成本,然后仅在效率仍然合适时增加 Worker:5 分钟的影片保持在 1 个 Worker 上,3 小时的影片会分散到
    --max-workers
    (API 上限为 10)。
  • 在耗时较长或成本较高的渲染前,向用户展示
    --plan
    。
    它会输出例如
    Plan: 4 workers, 1 h 50 min of render work, ready in about 35 min, estimated $1.20.
  • 输出每个阶段占一行(
    probing
    、
    rendering N chunks and the audio
    、
    stitching
    、
    Done in …: <file>, <GPU seconds>, <cost>.
    ),进度和当前成本最多每 10 秒输出一次。让它在后台运行并等待完成;Ctrl-C 会取消任务(已使用的 GPU 时间仍会计费)。

From code

从代码调用

No GPU needed locally:
ts
import { CloudRenderError, renderCloud } from "framefields/cloud";

try {
  const result = await renderCloud({
    render: "film",                 // or { entry: "src/film.ts", export: "buildFilm", workers: "auto" }
    outputPath: "output/film.mp4",
    onProgress: (s) => console.log(s.status, s.progress.frames, s.progress.totalFrames, s.costUsd),
    // dryRun: true                 // plan only: result.plan, result.estimateUsd
  });
  console.log(result.filePath, result.gpuSeconds, result.costUsd);
} catch (err) {
  if (err instanceof CloudRenderError) console.error(err.code, err.message);
  else throw err;
}
Options override the named render's;
signal
cancels.
cloudClient({ apiKey })
exposes
start
,
status
,
cancel
. HTTP:
POST /v1/render
(
source
,
target
,
render
,
workers
,
max_workers
,
dry_run
,
name
,
title
),
GET
/
DELETE /v1/render/:id
,
Authorization: Bearer <key>
.
本地无需 GPU:
ts
import { CloudRenderError, renderCloud } from "framefields/cloud";

try {
  const result = await renderCloud({
    render: "film",                 // or { entry: "src/film.ts", export: "buildFilm", workers: "auto" }
    outputPath: "output/film.mp4",
    onProgress: (s) => console.log(s.status, s.progress.frames, s.progress.totalFrames, s.costUsd),
    // dryRun: true                 // plan only: result.plan, result.estimateUsd
  });
  console.log(result.filePath, result.gpuSeconds, result.costUsd);
} catch (err) {
  if (err instanceof CloudRenderError) console.error(err.code, err.message);
  else throw err;
}
Options 会覆盖 named render 的对应配置;
signal
可取消任务。
cloudClient({ apiKey })
暴露
start
、
status
和
cancel
。HTTP 接口:
POST /v1/render
(
source
、
target
、
render
、
workers
、
max_workers
、
dry_run
、
name
、
title
),
GET
/
DELETE /v1/render/:id
,
Authorization: Bearer <key>
。

Billing and the dashboard

计费与 dashboard

  • A credit hold is placed at start (raised to the estimate once planned); the charge is the GPU seconds used, the rest is released. Failed and cancelled renders charge what they used.
  • insufficient_credits
    : the user adds funds at https://framefields.dev/dashboard/billing. Don't retry.
  • https://framefields.dev/dashboard/renders shows every render with live progress, cost, Cancel and the video. New render lists the named renders of a connected repo's branch (greyed out when
    entry
    isn't on that branch), with Plan and Render.
  • 渲染开始时会预扣一笔 credits(完成规划后调整为估算值);费用按实际使用的 GPU 秒数计算,其余部分会释放。失败和取消的渲染也会按已使用量收费。
  • insufficient_credits
    :用户需在 https://framefields.dev/dashboard/billing 充值。不要重试。
  • https://framefields.dev/dashboard/renders 会展示每次 render 的实时进度、成本、Cancel 按钮和视频。New render 会列出已连接 repo 的 branch 上的 named renders(如果该 branch 上不存在
    entry
    ,则将其置灰),并提供 Plan 和 Render。

Errors

错误

The error carries the worker's code. Fix the project, commit, push, render again.
CodeFix
REPO_NOT_FOUND
,
GIT_AUTH_FAILED
Connect GitHub (Settings → Connections) with access to this repo.
REF_NOT_FOUND
,
COMMIT_MISMATCH
git push
.
LOCKFILE_MISSING
,
INSTALL_FAILED
Commit a lockfile that installs cleanly.
ENTRY_NOT_FOUND
,
EXPORT_NOT_FOUND
,
EXPORT_INVALID
Fix
entry
/
export
;
framefields check <name>
.
COMPOSITION_BUILD_FAILED
,
EXPORT_SIDE_EFFECT
The builder throws or renders/writes;
framefields check
reproduces it.
ASSET_NOT_FOUND
,
LFS_OBJECT_MISSING
,
LFS_POINTER_UNRESOLVED
git lfs ls-files
,
git lfs push --all origin
; un-ignore needed assets.
ASSET_NOT_UPLOADED
,
ASSET_HASH_MISMATCH
npx framefields assets push
from the machine with the right file.
ASSET_PRIVATE
,
ASSET_FORBIDDEN
Dashboard render of a remote without a working
publicUrl
: render from the CLI or fix
publicUrl
.
ASSET_MANIFEST_INVALID
npx framefields assets status
shows the error.
ENGINE_UNSUPPORTED
Upgrade framefields (2.11+) or use
--workers 1
.
RENDER_TIMEOUT
,
RENDER_OOM
--workers auto
or more workers.
Infrastructure errors (
GIT_NETWORK
,
RENDER_STALLED
, a lost worker) are retried by the API, and a straggling chunk gets a backup worker.
A stitched video with a jump at a chunk seam means a stateful effect reads wall-clock time; keep effects deterministic in the frame number.
错误对象会携带 Worker 返回的代码。修复项目后,commit、push 并再次渲染。
代码修复方法
REPO_NOT_FOUND
、
GIT_AUTH_FAILED
连接 GitHub(Settings → Connections),并确保其有权访问此 repo。
REF_NOT_FOUND
、
COMMIT_MISMATCH
执行
git push
。
LOCKFILE_MISSING
、
INSTALL_FAILED
提交一个能够顺利安装的 lockfile。
ENTRY_NOT_FOUND
、
EXPORT_NOT_FOUND
、
EXPORT_INVALID
修正
entry
/
export
;运行
framefields check <name>
。
COMPOSITION_BUILD_FAILED
、
EXPORT_SIDE_EFFECT
Builder 抛出异常,或在构建期间执行渲染/写入;
framefields check
可复现该问题。
ASSET_NOT_FOUND
、
LFS_OBJECT_MISSING
、
LFS_POINTER_UNRESOLVED
运行
git lfs ls-files
、
git lfs push --all origin
;将所需 assets 从 ignore 规则中移除。
ASSET_NOT_UPLOADED
、
ASSET_HASH_MISMATCH
在拥有正确文件的机器上运行
npx framefields assets push
。
ASSET_PRIVATE
、
ASSET_FORBIDDEN
在 dashboard 中渲染一个没有可用
publicUrl
的 remote:从 CLI 发起渲染,或修复
publicUrl
。
ASSET_MANIFEST_INVALID
npx framefields assets status
会显示具体错误。
ENGINE_UNSUPPORTED
升级 framefields(2.11+)或使用
--workers 1
。
RENDER_TIMEOUT
、
RENDER_OOM
使用
--workers auto
或增加 Worker 数量。
基础设施错误(
GIT_NETWORK
、
RENDER_STALLED
、Worker 丢失)会由 API 自动重试;如果某个 chunk 滞留,则会为其分配备用 Worker。
如果拼接后的视频在 chunk 接缝处出现跳变,说明某个有状态 effect 读取了 wall-clock time;应确保 effects 根据 frame number 保持确定性。

Self-hosted render worker

自托管 render worker

The same worker runs on your own GPU (Docker, RunPod pod or serverless): it renders a pushed commit with the rules above and uploads the result. A failed job returns
{ code, hint, retryable }
; resubmit unchanged only when
retryable
is true. Job format: https://framefields.dev/docs/guides/render-service/
To split a render yourself, see Splitting a long render in
framefields-render
.
同一个 Worker 也可以运行在你自己的 GPU 上(Docker、RunPod pod 或 serverless):它会按照上述规则渲染已 push 的 commit,并上传结果。失败的任务会返回
{ code, hint, retryable }
;仅当
retryable
为 true 时,才可原样重新提交。任务格式:https://framefields.dev/docs/guides/render-service/
有关如何自行拆分渲染,请参阅
framefields-render
中的 Splitting a long render。