Skip to content

πŸŽ₯ Make videos programmatically with React

cool!

JonnyBurgerab3932aba90f
diff --git a/.claude/commands/update-chrome-binaries-test-region.md b/.claude/commands/update-chrome-binaries-test-region.md
index ae320ec086..1bc8755dfc 100644
--- a/.claude/commands/update-chrome-binaries-test-region.md
+++ b/.claude/commands/update-chrome-binaries-test-region.md
@@ -10,6 +10,8 @@
- `packages/docs/docs/lambda/runtime.mdx`: prepend a new row to the "Chrome" version table for the next Remotion release. Determine the next version with `cat packages/core/package.json | grep '"version"'` and increment the patch.
- `packages/docs/docs/miscellaneous/chrome-headless-shell.mdx`: prepend a new row to the version table, and update the example version string in the "Version tracking" section.
- `packages/docs/docs/renderer/ensure-browser.mdx`: update both `version: '<old>'` occurrences in the example code blocks.
-- Run the Docker matrix tests in `packages/dockerfiles/` (`./run.sh`) against the new Chrome binary. Each Dockerfile renders two compositions from the `BrowserTestRoot`: `browser-test` (Three.js / WebGL / codec smoke test) and `html-in-canvas` (experimental `drawElementImage()` API β€” falls back to a "not supported" frame if the flag/version is unavailable). Outputs land in `packages/dockerfiles/out/<platform>.mp4` and `packages/dockerfiles/out/<platform>-html-in-canvas.mp4`. Make sure Docker Desktop is running first.
-- If a new composition is added to the Docker test matrix, register it in `packages/example/src/BrowserTestRoot.tsx` (so it is included in the bundle built from `src/browser-test-entry.ts`) and add a corresponding `RUN npx remotion render /usr/app/bundle <id> /usr/app/<filename>.mp4` line + `docker cp` extraction in `run.sh`.
+- Run the Docker matrix tests in `packages/dockerfiles/` (`./run.sh`) against the new Chrome binary. Each Dockerfile renders two compositions from the `BrowserTestRoot`: `browser-test` (Three.js / WebGL / codec smoke test) and `html-in-canvas` (experimental WICG `drawElementImage()` + `canvas.requestPaint()` APIs). Outputs land in `packages/dockerfiles/out/<platform>.mp4` and `packages/dockerfiles/out/<platform>-html-in-canvas.mp4`. Make sure Docker Desktop is running first.
+- The Dockerfiles install the **local** workspace build of `@remotion/cli` + transitive deps (not the published version), so source changes in `@remotion/renderer` (e.g. new Chrome flags) are picked up before publishing. `run.sh` runs `pack-cli.ts` which auto-walks `@remotion/cli`'s transitive `workspace:*` deps, runs `bun pm pack` for each into `packages/dockerfiles/tarballs/`, and emits `local-cli-package.json` (lists every tarball as a direct dep AND in `overrides`, to force resolution to the local copies). Each Dockerfile then `COPY`s `tarballs/` and `local-cli-package.json` and runs `bun install` + adds `node_modules/.bin` to PATH.
+- If a new composition is added to the Docker test matrix, register it in `packages/example/src/BrowserTestRoot.tsx` (so it is included in the bundle built from `src/browser-test-entry.ts`) and add a corresponding `RUN remotion render /usr/app/bundle <id> /usr/app/<filename>.mp4` line + `docker cp` extraction in `run.sh`.
+- The `html-in-canvas` composition's runtime check (`packages/example/src/HtmlInCanvas/html-in-canvas.tsx`) requires both `ctx.drawElementImage` and `canvas.requestPaint`, which Chrome 149+ exposes when `--enable-features=CanvasDrawElement` is passed (already wired into `featuresToEnable()` at `packages/renderer/src/open-browser.ts:50`). If `html-in-canvas` renders fail with `"HTML in Canvas is not supported"` while `browser-test` passes, the most likely cause is a Chrome **version** mismatch β€” e.g. the Dockerfiles are using a published `@remotion/cli` whose `TESTED_VERSION` predates the new Chrome, so it re-downloads the older binary on top of the one `ensure.mjs` already fetched. The local-tarball install path in `pack-cli.ts` + `local-cli-package.json` is what guarantees `ensure.mjs` and the render CLI agree on the same `TESTED_VERSION`.
- Do not proceed to publishing all regions until the test region has been verified end-to-end.
diff --git a/packages/dockerfiles/.gitignore b/packages/dockerfiles/.gitignore
index 995923cba8..eef7c65f35 100644
--- a/packages/dockerfiles/.gitignore
+++ b/packages/dockerfiles/.gitignore
@@ -1,5 +1,5 @@
ensure-browser.mjs
bundle/
out/
-
-bundle
\ No newline at end of file
+tarballs/
+local-cli-package.json
\ No newline at end of file
diff --git a/packages/dockerfiles/Dockerfile.al2023 b/packages/dockerfiles/Dockerfile.al2023
index c06395738a..3cc438c126 100644
--- a/packages/dockerfiles/Dockerfile.al2023
+++ b/packages/dockerfiles/Dockerfile.al2023
@@ -1,9 +1,16 @@
FROM amazonlinux:2023
WORKDIR /usr/app
-RUN yum install git -y
+RUN yum install git tar gzip unzip -y
RUN yum install nodejs -y
-RUN npm i -g @remotion/cli
+RUN curl -fsSL https://bun.com/install | bash && ln -s /root/.bun/bin/bun /usr/local/bin/bun
+
+# Install the local @remotion/cli build from packed workspace tarballs.
+COPY tarballs/ /usr/app/tarballs/
+COPY local-cli-package.json /usr/app/package.json
+RUN bun install
+ENV PATH="/usr/app/node_modules/.bin:$PATH"
+
RUN yum install -y \
mesa-libgbm \
libX11 \
@@ -29,6 +36,6 @@ RUN node ensure.mjs
# Copy the pre-built bundle
COPY bundle/ /usr/app/bundle/
-RUN npx remotion compositions /usr/app/bundle
-RUN npx remotion render /usr/app/bundle browser-test /usr/app/out.mp4
-RUN npx remotion render /usr/app/bundle html-in-canvas /usr/app/out-html-in-canvas.mp4
+RUN remotion compositions /usr/app/bundle
+RUN remotion render /usr/app/bundle browser-test /usr/app/out.mp4
+RUN remotion render /usr/app/bundle html-in-canvas /usr/app/out-html-in-canvas.mp4
diff --git a/packages/dockerfiles/Dockerfile.debian b/packages/dockerfiles/Dockerfile.debian
index b3fffc6a23..dc7dbaf6c7 100644
--- a/packages/dockerfiles/Dockerfile.debian
+++ b/packages/dockerfiles/Dockerfile.debian
@@ -5,6 +5,8 @@ WORKDIR /usr/app
RUN apt install -y \
git \
+ curl \
+ unzip \
libnss3 \
libdbus-1-3 \
libatk1.0-0 \
@@ -20,7 +22,13 @@ RUN apt install -y \
libcups2 \
libcairo2
-RUN npm i -g @remotion/cli
+RUN curl -fsSL https://bun.com/install | bash && ln -s /root/.bun/bin/bun /usr/local/bin/bun
+
+# Install the local @remotion/cli build from packed workspace tarballs.
+COPY tarballs/ /usr/app/tarballs/
+COPY local-cli-package.json /usr/app/package.json
+RUN bun install
+ENV PATH="/usr/app/node_modules/.bin:$PATH"
COPY ensure-browser.mjs .
COPY ensure.mjs .
@@ -29,6 +37,6 @@ RUN node ensure.mjs
# Copy the pre-built bundle
COPY bundle/ /usr/app/bundle/
-RUN npx remotion compositions /usr/app/bundle
-RUN npx remotion render /usr/app/bundle browser-test /usr/app/out.mp4
-RUN npx remotion render /usr/app/bundle html-in-canvas /usr/app/out-html-in-canvas.mp4
+RUN remotion compositions /usr/app/bundle
+RUN remotion render /usr/app/bundle browser-test /usr/app/out.mp4
+RUN remotion render /usr/app/bundle html-in-canvas /usr/app/out-html-in-canvas.mp4
diff --git a/packages/dockerfiles/Dockerfile.ubuntu22 b/packages/dockerfiles/Dockerfile.ubuntu22
index 317db988d3..e4ce8bf46b 100644
--- a/packages/dockerfiles/Dockerfile.ubuntu22
+++ b/packages/dockerfiles/Dockerfile.ubuntu22
@@ -1,10 +1,17 @@
FROM ubuntu:22.04
RUN apt-get update
-RUN apt-get install git curl make -y
+RUN apt-get install git curl make unzip -y
RUN curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s 20
+RUN curl -fsSL https://bun.com/install | bash && ln -s /root/.bun/bin/bun /usr/local/bin/bun
WORKDIR /usr/app
-RUN npm i -g @remotion/cli
+
+# Install the local @remotion/cli build from packed workspace tarballs.
+COPY tarballs/ /usr/app/tarballs/
+COPY local-cli-package.json /usr/app/package.json
+RUN bun install
+ENV PATH="/usr/app/node_modules/.bin:$PATH"
+
RUN apt install -y \
libnss3 \
libdbus-1-3 \
@@ -28,6 +35,6 @@ RUN node ensure.mjs
# Copy the pre-built bundle
COPY bundle/ /usr/app/bundle/
-RUN npx remotion compositions /usr/app/bundle
-RUN npx remotion render /usr/app/bundle browser-test /usr/app/out.mp4 --log=verbose
-RUN npx remotion render /usr/app/bundle html-in-canvas /usr/app/out-html-in-canvas.mp4 --log=verbose
\ No newline at end of file
+RUN remotion compositions /usr/app/bundle
+RUN remotion render /usr/app/bundle browser-test /usr/app/out.mp4 --log=verbose
+RUN remotion render /usr/app/bundle html-in-canvas /usr/app/out-html-in-canvas.mp4 --log=verbose
\ No newline at end of file
diff --git a/packages/dockerfiles/Dockerfile.ubuntu24 b/packages/dockerfiles/Dockerfile.ubuntu24
index 9c3882f7d6..4d6c8c9fc2 100644
--- a/packages/dockerfiles/Dockerfile.ubuntu24
+++ b/packages/dockerfiles/Dockerfile.ubuntu24
@@ -1,10 +1,18 @@
FROM ubuntu:24.04
RUN apt-get update
-RUN apt-get install git curl make -y
+RUN apt-get install git curl make unzip -y
RUN curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s 20
+RUN curl -fsSL https://bun.com/install | bash && ln -s /root/.bun/bin/bun /usr/local/bin/bun
WORKDIR /usr/app
-RUN npm i -g @remotion/cli
+
+# Install the local @remotion/cli build (with our renderer flag changes)
+# from the workspace tarballs packed by run.sh.
+COPY tarballs/ /usr/app/tarballs/
+COPY local-cli-package.json /usr/app/package.json
+RUN bun install
+ENV PATH="/usr/app/node_modules/.bin:$PATH"
+
RUN apt install -y \
libnss3 \
libdbus-1-3 \
@@ -28,6 +36,6 @@ RUN node ensure.mjs
# Copy the pre-built bundle
COPY bundle/ /usr/app/bundle/
-RUN npx remotion compositions /usr/app/bundle
-RUN npx remotion render /usr/app/bundle browser-test /usr/app/out.mp4 --log=verbose
-RUN npx remotion render /usr/app/bundle html-in-canvas /usr/app/out-html-in-canvas.mp4 --log=verbose
\ No newline at end of file
+RUN remotion compositions /usr/app/bundle
+RUN remotion render /usr/app/bundle browser-test /usr/app/out.mp4 --log=verbose
+RUN remotion render /usr/app/bundle html-in-canvas /usr/app/out-html-in-canvas.mp4 --log=verbose
\ No newline at end of file
diff --git a/packages/dockerfiles/pack-cli.ts b/packages/dockerfiles/pack-cli.ts
new file mode 100644
index 0000000000..1662405f1a
--- /dev/null
+++ b/packages/dockerfiles/pack-cli.ts
@@ -0,0 +1,87 @@
+// Walk the transitive workspace dependencies of @remotion/cli and pack each
+// one with `bun pm pack`, so the Dockerfiles can install the local build of
+// the renderer (with our --enable-blink-features=CanvasDrawElement change)
+// instead of pulling the published version from npm.
+import {readFileSync, readdirSync, rmSync, mkdirSync, writeFileSync} from 'fs';
+import {join, resolve} from 'path';
+import {$} from 'bun';
+
+const ROOT = resolve(import.meta.dir, '../..');
+const PACKAGES_DIR = join(ROOT, 'packages');
+const OUT_DIR = resolve(import.meta.dir, 'tarballs');
+
+type Pkg = {name: string; dir: string; deps: string[]};
+
+const readPkg = (dir: string): Pkg | null => {
+ try {
+ const json = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf-8'));
+ const deps = {
+ ...json.dependencies,
+ ...json.peerDependencies,
+ ...json.optionalDependencies,
+ };
+ const wsDeps = Object.entries(deps)
+ .filter(([, v]) => typeof v === 'string' && (v as string).startsWith('workspace:'))
+ .map(([k]) => k);
+ return {name: json.name, dir, deps: wsDeps};
+ } catch {
+ return null;
+ }
+};
+
+const allPkgs: Record<string, Pkg> = {};
+for (const entry of readdirSync(PACKAGES_DIR)) {
+ const dir = join(PACKAGES_DIR, entry);
+ const pkg = readPkg(dir);
+ if (pkg) allPkgs[pkg.name] = pkg;
+}
+
+const visited = new Set<string>();
+const order: Pkg[] = [];
+const visit = (name: string) => {
+ if (visited.has(name)) return;
+ visited.add(name);
+ const pkg = allPkgs[name];
+ if (!pkg) return;
+ for (const d of pkg.deps) visit(d);
+ order.push(pkg);
+};
+
+visit('@remotion/cli');
+console.log(`Packing ${order.length} workspace packages...`);
+
+rmSync(OUT_DIR, {recursive: true, force: true});
+mkdirSync(OUT_DIR, {recursive: true});
+
+for (const pkg of order) {
+ console.log(` pack ${pkg.name}`);
+ await $`cd ${pkg.dir} && bun pm pack --destination ${OUT_DIR} --quiet`.quiet();
+}
+
+console.log(`\nTarballs in ${OUT_DIR}:`);
+for (const f of readdirSync(OUT_DIR).sort()) console.log(` ${f}`);
+
+// Map package name -> its tarball filename (relative to the Docker workdir
+// where this package.json will be installed).
+const tarballByName: Record<string, string> = {};
+for (const pkg of order) {
+ const json = JSON.parse(readFileSync(join(pkg.dir, 'package.json'), 'utf-8'));
+ const safe = pkg.name.replace('@', '').replace('/', '-');
+ tarballByName[pkg.name] = `./tarballs/${safe}-${json.version}.tgz`;
+}
+
+// Generate a package.json that lists every workspace tarball as a direct
+// dependency AND adds an `overrides` entry, so transitive resolution picks
+// the local tarball instead of the same-versioned registry copy.
+const localPkg = {
+ name: 'remotion-local-cli-runner',
+ private: true,
+ version: '0.0.0',
+ dependencies: tarballByName,
+ overrides: tarballByName,
+};
+writeFileSync(
+ resolve(import.meta.dir, 'local-cli-package.json'),
+ JSON.stringify(localPkg, null, 2) + '\n',
+);
+console.log('\nWrote local-cli-package.json');
diff --git a/packages/dockerfiles/run.sh b/packages/dockerfiles/run.sh
index cb7337e42f..7555e0b104 100644
--- a/packages/dockerfiles/run.sh
+++ b/packages/dockerfiles/run.sh
@@ -4,6 +4,13 @@ bun build-browser-downloader.ts
cp ensure-browser.mjs ../dockerfiles/ensure-browser.mjs
cd ../dockerfiles
+# Pack the local @remotion/cli + transitive workspace deps into ./tarballs/
+# and emit ./local-cli-package.json so each Docker image installs the local
+# build (e.g. flag changes in @remotion/renderer) instead of the published
+# version from npm.
+echo "Packing local @remotion/cli and transitive deps..."
+bun pack-cli.ts
+
# Build the browser-test bundle from packages/example
echo "Building browser-test bundle..."
cd ../example