Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
fix(render): allow resolution scaling for alpha output (#3634)
Miguel Ángele0007b86e0e6
diff --git a/packages/cli/src/commands/render.test.ts b/packages/cli/src/commands/render.test.tsindex 35f4760a9b..1e37506211 100644--- a/packages/cli/src/commands/render.test.ts+++ b/packages/cli/src/commands/render.test.ts@@ -1283,16 +1283,15 @@ describe("checkRenderResolutionPreflight", () => {).toBeUndefined();});- it("flags alpha output combined with outputResolution", async () => {+ it("allows alpha output combined with an integer outputResolution scale", async () => {const result = await checkRenderResolutionPreflight(landscapeHtml, "landscape-4k", {alphaRequested: true,hdrRequested: false,});- expect(result?.message).toContain("alpha output");- expect(result?.kind).toBe("alpha-incompatible");+ expect(result).toBeUndefined();});- // The three remaining kinds share the same rejection sink (→ one emit each);+ // The remaining kinds share the same rejection sink (→ one emit each);// guard their classification so the telemetry dimension stays accurate.it("classifies an HDR + outputResolution combination as hdr-incompatible", async () => {const result = await checkRenderResolutionPreflight(landscapeHtml, "landscape", {@@ -1357,16 +1356,13 @@ describe("checkRenderResolutionPreflight", () => {).toBeUndefined();});- it("still flags alpha + aspect-agnostic (orientation isn't the issue)", async () => {- // alpha-incompatible is orthogonal to aspect: the alpha capture path- // can't apply deviceScaleFactor regardless of orientation. The- // aspect-agnostic downgrade must NOT swallow this.+ it("allows alpha + aspect-agnostic after adapting the orientation", async () => {const result = await checkRenderResolutionPreflight(portraitHtml, "landscape", {aspectAgnostic: true,alphaRequested: true,hdrRequested: false,});- expect(result?.kind).toBe("alpha-incompatible");+ expect(result).toBeUndefined();});it("still flags HDR + aspect-agnostic", async () => {diff --git a/packages/cli/src/telemetry/events.ts b/packages/cli/src/telemetry/events.tsindex fb8737c53e..965c47f718 100644--- a/packages/cli/src/telemetry/events.ts+++ b/packages/cli/src/telemetry/events.ts@@ -648,10 +648,10 @@ export function identifyUser(distinctId: string): void {trackEvent("$identify", { $anon_distinct_id: readConfig().anonymousId }, distinctId);}-// A render was rejected by the output-resolution/alpha/HDR pre-flight (P1-3)+// A render was rejected by the output-resolution/HDR pre-flight (P1-3)// before any browser/ffmpeg work. Counts the "caught early" saves on dashboard// 1783183, distinct from deep render failures. `kind` is the low-cardinality-// `OutputResolutionIssueKind` (aspect-mismatch / alpha-incompatible / etc.),+// `OutputResolutionIssueKind` (aspect-mismatch / hdr-incompatible / etc.),// typed to the union so the metric can never carry free text.export function trackRenderPreflightRejected(props: { kind: OutputResolutionIssueKind }): void {trackEvent("render_preflight_rejected", { kind: props.kind });diff --git a/packages/parsers/src/outputResolutionCompatibility.test.ts b/packages/parsers/src/outputResolutionCompatibility.test.tsindex bf80f970e8..9e154e35f1 100644--- a/packages/parsers/src/outputResolutionCompatibility.test.ts+++ b/packages/parsers/src/outputResolutionCompatibility.test.ts@@ -81,18 +81,15 @@ describe("checkOutputResolutionCompatibility", () => {});});- describe("alpha / HDR incompatibility", () => {- it("flags alpha output combined with outputResolution", () => {+ describe("alpha / HDR compatibility", () => {+ it("allows alpha output to use integer deviceScaleFactor supersampling", () => {const result = checkOutputResolutionCompatibility({compositionWidth: 1920,compositionHeight: 1080,outputResolution: "landscape-4k",alphaRequested: true,});- expect(result.ok).toBe(false);- expect(result.kind).toBe("alpha-incompatible");- expect(result.message).toContain("alpha output");- expect(result.message).toContain("--format mp4");+ expect(result).toEqual({ ok: true });});it("flags HDR combined with outputResolution", () => {diff --git a/packages/parsers/src/outputResolutionCompatibility.ts b/packages/parsers/src/outputResolutionCompatibility.tsindex 4f0c20bf6f..e9f13333a6 100644--- a/packages/parsers/src/outputResolutionCompatibility.ts+++ b/packages/parsers/src/outputResolutionCompatibility.ts@@ -27,7 +27,6 @@ import { CANVAS_DIMENSIONS, VALID_CANVAS_RESOLUTIONS, type CanvasResolution } frexport type OutputResolutionIssueKind =| "hdr-incompatible"- | "alpha-incompatible"| "aspect-mismatch"| "downsampling"| "non-integer-scale";@@ -124,7 +123,7 @@ function buildAspectMismatch(/*** Check whether rendering a composition of the given dimensions with the given- * `outputResolution` preset (and alpha/HDR modes) is supported.+ * `outputResolution` preset (and HDR mode) is supported.** Pure and dependency-free — the single source of truth for the constraints* `resolveDeviceScaleFactor` enforces, so the CLI can run the exact same check@@ -154,18 +153,6 @@ export function checkOutputResolutionCompatibility(input: {};}- if (input.alphaRequested) {- return {- ok: false,- kind: "alpha-incompatible",- message:- `outputResolution cannot be combined with alpha output (--format webm|mov|png-sequence). ` +- `The alpha screenshot path does not yet apply deviceScaleFactor and would silently ` +- `produce composition-resolution frames. Render alpha at composition resolution and ` +- `upscale separately, or use --format mp4.`,- };- }-const target = CANVAS_DIMENSIONS[outputResolution];// Aspect-ratio compare via cross-multiplication so the equality is integer-// safe. Float division (`target.width / compositionWidth`) loses precisiondiff --git a/packages/producer/src/services/render/shared.ts b/packages/producer/src/services/render/shared.tsindex e48f3f5180..69fc3fe83e 100644--- a/packages/producer/src/services/render/shared.ts+++ b/packages/producer/src/services/render/shared.ts@@ -119,10 +119,10 @@ export function resolveDeviceScaleFactor(input: {alphaRequested: boolean;}): number {if (!input.outputResolution) return 1;- // Single source of truth for the aspect/alpha/HDR/scale constraints, shared+ // Single source of truth for the aspect/HDR/scale constraints, shared// with the CLI render pre-flight so both raise the identical, actionable// message. This is the deep defense-in-depth throw; the pre-flight aborts- // long before this runs on the common (aspect/alpha) mistakes.+ // long before this runs on common compatibility mistakes.const compat = checkOutputResolutionCompatibility({compositionWidth: input.compositionWidth,compositionHeight: input.compositionHeight,diff --git a/packages/producer/src/services/renderOrchestrator.test.ts b/packages/producer/src/services/renderOrchestrator.test.tsindex 1a91346c7e..1e04850145 100644--- a/packages/producer/src/services/renderOrchestrator.test.ts+++ b/packages/producer/src/services/renderOrchestrator.test.ts@@ -1598,14 +1598,14 @@ describe("resolveDeviceScaleFactor", () => {).toThrow(/hdrMode='force-hdr'/);});- it("rejects alpha + outputResolution (the alpha capture path doesn't apply DPR yet)", () => {- expect(() =>+ it("returns the requested DPR for alpha + outputResolution", () => {+ expect(resolveDeviceScaleFactor({...defaults,outputResolution: "landscape-4k",alphaRequested: true,}),- ).toThrow(/alpha output/);+ ).toBe(2);});it("rejects orientation mismatch (landscape comp → portrait-4k)", () => {