Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Offer larger video resolutions and standard export sizes

Bittiecad5582799e
diff --git a/src-tauri/src/project/validation/values.rs b/src-tauri/src/project/validation/values.rs
index f95761b..9bdcc02 100644
--- a/src-tauri/src/project/validation/values.rs
+++ b/src-tauri/src/project/validation/values.rs
@@ -5,7 +5,7 @@ pub(crate) fn is_supported_aspect_ratio(value: &str) -> bool {
/// The same names `resolutionSchema` in src/lib/project.ts accepts, and no
/// others in either direction — this layer writes the file the frontend then
-/// has to parse. The first eight include the two larger still-image sizes, every
+/// has to parse. The first eight are the ladder a new project is created at, every
/// rung a multiple of 32 on both edges because that is what MiniMax H3
/// generates at; the last three are names already on disk, kept so a project
/// saved before the ladder was rebuilt still opens at the pixels it always had.
diff --git a/src/App.test.tsx b/src/App.test.tsx
index 1530644..bd51210 100644
--- a/src/App.test.tsx
+++ b/src/App.test.tsx
@@ -228,7 +228,7 @@ describe("project library controls", () => {
// The ladder the user asked for, in pixels rather than a name for them.
expect(optionNames(size)).toEqual([
- "736 × 416", "960 × 544", "1152 × 640", "1376 × 768 (default)", "1920 × 1088", "2432 × 1344",
+ "736 × 416", "960 × 544", "1152 × 640", "1376 × 768 (default)", "1920 × 1088", "2432 × 1344", "2720 × 1536", "3648 × 2048",
]);
// Every edge a multiple of 32 — the whole reason the old 720p/1080p/4K
// ladder was replaced.
@@ -241,7 +241,7 @@ describe("project library controls", () => {
old labels ("1080p HD") could sit above either and say nothing. */
chooseOption(shape, "Vertical 9:16");
expect(optionNames(size)).toEqual([
- "416 × 736", "544 × 960", "640 × 1152", "768 × 1376 (default)", "1088 × 1920", "1344 × 2432",
+ "416 × 736", "544 × 960", "640 × 1152", "768 × 1376 (default)", "1088 × 1920", "1344 × 2432", "1536 × 2720", "2048 × 3648",
]);
chooseOption(size, "544 × 960");
diff --git a/src/components/ImageProject.integration.test.tsx b/src/components/ImageProject.integration.test.tsx
index f190a84..2b77703 100644
--- a/src/components/ImageProject.integration.test.tsx
+++ b/src/components/ImageProject.integration.test.tsx
@@ -169,8 +169,9 @@ it("offers image and video projects when creating a folder project", async () =>
fireEvent.click(screen.getByRole("radio", { name: "Image project" }));
expect(screen.getByLabelText("Project name")).toHaveValue("Untitled image");
choose("Resolution", "2720 × 1536");
+ // Video offers the same larger sizes, so switching keeps the choice.
fireEvent.click(screen.getByRole("radio", { name: "Video project" }));
- expect(screen.getByRole("combobox", { name: "Resolution" })).toHaveTextContent("1376 × 768 (default)");
+ expect(screen.getByRole("combobox", { name: "Resolution" })).toHaveTextContent("2720 × 1536");
fireEvent.click(screen.getByRole("radio", { name: "Image project" }));
choose("Resolution", "3648 × 2048");
fireEvent.click(screen.getByRole("button", { name: /Create project/ }));
diff --git a/src/components/PromptComposer.tsx b/src/components/PromptComposer.tsx
index e1219e4..45366ce 100644
--- a/src/components/PromptComposer.tsx
+++ b/src/components/PromptComposer.tsx
@@ -2,7 +2,7 @@ import { useEffect, useId, useRef, useState } from "react";
import { outputDimensions } from "../lib/export";
import { useShortcut } from "../lib/commands";
import type { AspectRatio, CreateProjectInput, ProjectConfig, Resolution } from "../lib/project";
-import { IMAGE_RESOLUTIONS, PROJECT_RESOLUTIONS } from "../lib/project";
+import { PROJECT_RESOLUTIONS } from "../lib/project";
import { SHOT_TAG_GROUPS } from "../lib/shot-tags";
import { ComboBox, ContentDialog, InfoBar, RadioGroup } from "./ui";
@@ -47,9 +47,8 @@ export function PromptComposer({ busy, onCreate: onSubmit, onClose, project, err
const [defaultLook, setDefaultLook] = useState(project?.settings.defaultLook ?? "");
const nameInput = useRef<HTMLInputElement>(null);
const id = useId();
- const availableResolutions: readonly Resolution[] = generationType === "image" ? IMAGE_RESOLUTIONS : PROJECT_RESOLUTIONS;
- const resolutions: readonly Resolution[] = project && !availableResolutions.includes(project.settings.resolution)
- ? [...availableResolutions, project.settings.resolution] : availableResolutions;
+ const resolutions: readonly Resolution[] = project && !PROJECT_RESOLUTIONS.some((value) => value === project.settings.resolution)
+ ? [...PROJECT_RESOLUTIONS, project.settings.resolution] : PROJECT_RESOLUTIONS;
const blocked = busy || Boolean(checkingFolder) || Boolean(folderError) || !name.trim();
const close = () => { if (!busy) onClose(); };
@@ -97,7 +96,6 @@ export function PromptComposer({ busy, onCreate: onSubmit, onClose, project, err
disabled={busy}
onChange={(type) => {
setGenerationType(type);
- if (type === "video" && !PROJECT_RESOLUTIONS.some((value) => value === resolution)) setResolution(DEFAULT_RESOLUTION);
if (!folderPath && (name === "Untitled video" || name === "Untitled image")) setName(`Untitled ${type}`);
}}
options={[
diff --git a/src/components/workspace/ExportView.test.tsx b/src/components/workspace/ExportView.test.tsx
index aa66fec..1b7b82c 100644
--- a/src/components/workspace/ExportView.test.tsx
+++ b/src/components/workspace/ExportView.test.tsx
@@ -7,6 +7,7 @@ import externalFixture from "../../../fixtures/project-v1-external-media.json";
import { createProjectConfig, parseProjectConfig, type ProjectConfig, type TimelineClip } from "../../lib/project";
import { resetExportJobForTests, setExportJobForTests } from "../../lib/exportJob";
import { ExportView } from "./ExportView";
+import { chooseOption, optionNames } from "./comboTestUtils";
vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));
@@ -65,6 +66,16 @@ describe("the export view where nothing can encode", () => {
expect(screen.getByRole("combobox", { name: "Resolution" }).textContent).toContain("1920 × 1080");
});
+ it("offers the project's own frame and then the standard delivery sizes", () => {
+ const config = project([clip("a", 0, 2_000)]);
+ config.settings.resolution = "1344p";
+ render(<ExportView config={config} folderPath="/tmp/project" />);
+ const resolution = screen.getByRole("combobox", { name: "Resolution" });
+ expect(optionNames(resolution)).toEqual(["2432 × 1344 (project)", "1280 × 720", "1920 × 1080", "2560 × 1440", "3840 × 2160"]);
+ chooseOption(resolution, "3840 × 2160");
+ expect(screen.getByText(/3840 × 2160/)).toBeTruthy();
+ });
+
it("says outright that a timeline with no audio clips produces no sound", () => {
render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);
expect(screen.getByText("no audio clips on the timeline")).toBeTruthy();
diff --git a/src/components/workspace/ExportView.tsx b/src/components/workspace/ExportView.tsx
index 67839e2..9833a8a 100644
--- a/src/components/workspace/ExportView.tsx
+++ b/src/components/workspace/ExportView.tsx
@@ -8,6 +8,8 @@ import {
estimatedBytes,
formatBytes,
formatDuration,
+ exportSizeChoices,
+ exportSizeKey,
outputDimensions,
OUTPUT_CODECS,
QUALITY_PRESETS,
@@ -39,18 +41,9 @@ import { askNative, messageNative, revealInExplorer } from "../../lib/nativeShel
import { formatTimecode, frameAt, frameStartMs } from "../../lib/timeline";
import { ProgramMonitor } from "./ProgramMonitor";
import { ProjectStatus } from "./ProjectStatus";
-import { PROJECT_RESOLUTIONS, type ProjectConfig, type Resolution } from "../../lib/project";
+import type { ProjectConfig } from "../../lib/project";
import { ComboBox, InfoBar, ProgressBar, PropRow, PropSection, Slider, Splitter, tooltipProps, usePaneSize } from "../ui";
-/* The ladder a project can be created at, plus the project's own size when that
- is one of the names from before the ladder was rebuilt. Dropping the legacy
- rung outright would leave a 1080p project looking at a list that does not
- contain what the project IS, and the first touch of any other field would
- have quietly resized the export. */
-const resolutionChoices = (current: Resolution): Resolution[] =>
- PROJECT_RESOLUTIONS.includes(current as (typeof PROJECT_RESOLUTIONS)[number])
- ? [...PROJECT_RESOLUTIONS]
- : [...PROJECT_RESOLUTIONS, current];
const FRAME_RATES: FrameRate[] = [24, 25, 30, 60];
const describe = (reason: unknown) => (reason instanceof Error ? reason.message : String(reason));
@@ -90,6 +83,7 @@ export function ExportView({ config, folderPath, onClose }: {
const [settings, setSettings] = useState<ExportSettings>(() => defaultExportSettings(config));
const settingsPane = usePaneSize("export.settings", 340, { min: 280, max: 560 });
const plan = useMemo(() => buildExportPlan(config, settings), [config, settings]);
+ const sizeChoices = exportSizeChoices(outputDimensions(config.settings.resolution, config.settings.aspectRatio), config.settings.aspectRatio, "project");
const bitrate = useMemo(
() => bitrateFor(plan.width, plan.height, plan.frameRate, settings.quality),
[plan.width, plan.height, plan.frameRate, settings.quality],
@@ -428,15 +422,18 @@ export function ExportView({ config, folderPath, onClose }: {
</PropRow>
<PropRow label="Resolution" htmlFor="export-resolution">
+ {/* The project's own frame first, then the standard sizes at its
+ aspect. A size this machine's encoders cannot take shows as
+ such under Codec, from the probe at that size. */}
<ComboBox
id="export-resolution"
- value={settings.resolution}
+ value={exportSizeKey(settings.width, settings.height)}
disabled={runningHere}
- onChange={(value) => setSettings({ ...settings, resolution: value as Resolution })}
- options={resolutionChoices(config.settings.resolution).map((resolution) => {
- const size = outputDimensions(resolution, config.settings.aspectRatio);
- return { value: resolution, label: `${size.width} × ${size.height}` };
- })}
+ onChange={(value) => {
+ const size = sizeChoices.find((choice) => choice.value === value);
+ if (size) setSettings({ ...settings, width: size.width, height: size.height });
+ }}
+ options={sizeChoices.map((choice) => ({ value: choice.value, label: choice.label }))}
/>
</PropRow>
diff --git a/src/components/workspace/ImageEditor.tsx b/src/components/workspace/ImageEditor.tsx
index 03b9746..c2c06bb 100644
--- a/src/components/workspace/ImageEditor.tsx
+++ b/src/components/workspace/ImageEditor.tsx
@@ -7,7 +7,7 @@ import { outputDimensions } from "../../lib/export";
import { compileImagePrompt } from "../../lib/imagePrompt";
import { createEmptyImage, restoreGeneratedImage, saveImageDraft } from "../../lib/imageHistory";
import { isTauri } from "../../lib/persistence";
-import { IMAGE_RESOLUTIONS, referenceTypeLabel, type ProjectConfig } from "../../lib/project";
+import { PROJECT_RESOLUTIONS, referenceTypeLabel, type ProjectConfig } from "../../lib/project";
import { defaultGeneratorTemplate, loadDebugOptionsEnabled, loadGeneratorTemplateSettings, subscribeDebugOptions, subscribeGeneratorTemplates, templateNeedsDownload, type GeneratorTemplate } from "../../lib/settings";
import { isWorkActive, type WorkItem } from "../../lib/workQueue";
import type { ConfigUpdate } from "./TimelineView";
@@ -591,7 +591,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene
<PropRow label="Steps" htmlFor={rootField("steps")}><input id={rootField("steps")} className="text-field" type="number" min="2" max="1000" value={scene.steps} onChange={(event) => { const value = Number(event.target.value); if (Number.isInteger(value) && value >= 2 && value <= 1000) commit({ ...scene, steps: value }); }} /></PropRow>
<PropRow label="Seed" htmlFor={rootField("seed")}><input id={rootField("seed")} className="text-field" type="number" min="-1" max={Number.MAX_SAFE_INTEGER} value={scene.seed} data-tooltip="-1 picks a random seed" onChange={(event) => { const value = Number(event.target.value); if (Number.isSafeInteger(value) && value >= -1) commit({ ...scene, seed: value }); }} /></PropRow>
<PropRow label="Aspect ratio" htmlFor={rootField("ratio")}><ComboBox id={rootField("ratio")} aria-label="Aspect ratio" value={config.settings.aspectRatio} options={["16:9", "9:16", "1:1", "4:5"].map((ratio) => ({ value: ratio, label: ratio }))} onChange={(value) => { const aspectRatio = value as ProjectConfig["settings"]["aspectRatio"]; onChange((current) => ({ ...current, settings: { ...current.settings, aspectRatio }, brief: { ...current.brief, aspectRatio } })); }} /></PropRow>
- <PropRow label="Resolution" htmlFor={rootField("resolution")}><ComboBox id={rootField("resolution")} aria-label="Resolution" value={config.settings.resolution} options={[...new Set([...IMAGE_RESOLUTIONS, config.settings.resolution])].map((resolution) => { const size = outputDimensions(resolution, config.settings.aspectRatio); return { value: resolution, label: `${size.width} × ${size.height}` }; })} onChange={(value) => { const resolution = value as ProjectConfig["settings"]["resolution"]; onChange((current) => ({ ...current, settings: { ...current.settings, resolution }, brief: { ...current.brief, resolution } })); }} /></PropRow>
+ <PropRow label="Resolution" htmlFor={rootField("resolution")}><ComboBox id={rootField("resolution")} aria-label="Resolution" value={config.settings.resolution} options={[...new Set([...PROJECT_RESOLUTIONS, config.settings.resolution])].map((resolution) => { const size = outputDimensions(resolution, config.settings.aspectRatio); return { value: resolution, label: `${size.width} × ${size.height}` }; })} onChange={(value) => { const resolution = value as ProjectConfig["settings"]["resolution"]; onChange((current) => ({ ...current, settings: { ...current.settings, resolution }, brief: { ...current.brief, resolution } })); }} /></PropRow>
</PropSection>
<PropSection title="Style" persistKey="image.style">
<PropRow label="Mode" htmlFor={rootField("mode")}><ComboBox id={rootField("mode")} aria-label="Mode" value={scene.style.mode} options={[{ value: "photo", label: "Photo" }, { value: "art", label: "Art" }]} onChange={(value) => commit({ ...scene, style: { ...scene.style, mode: value as "photo" | "art" } })} /></PropRow>
diff --git a/src/components/workspace/ImageExportView.tsx b/src/components/workspace/ImageExportView.tsx
index f7c25d4..d897987 100644
--- a/src/components/workspace/ImageExportView.tsx
+++ b/src/components/workspace/ImageExportView.tsx
@@ -1,6 +1,7 @@
import { invoke } from "@tauri-apps/api/core";
import { useState } from "react";
-import type { AspectRatio, ProjectConfig } from "../../lib/project";
+import { exportSizeChoices } from "../../lib/export";
+import type { ProjectConfig } from "../../lib/project";
import { isTauri } from "../../lib/persistence";
import { ComboBox, EmptyState, InfoBar, PropRow, PropSection, Slider, Splitter, tooltipProps, usePaneSize } from "../ui";
import { Image32 } from "../ui/icons";
@@ -18,13 +19,6 @@ type ImageFormat = "jpg" | "png";
const STORAGE_KEY = "slopus.image-export.v1";
const DEFAULT_QUALITY = 90;
-const EXPORT_SIZES: Record<AspectRatio, readonly (readonly [number, number])[]> = {
- "16:9": [[1280, 720], [1920, 1080], [2560, 1440], [3840, 2160]],
- "9:16": [[720, 1280], [1080, 1920], [1440, 2560], [2160, 3840]],
- "1:1": [[512, 512], [1024, 1024], [1080, 1080], [2048, 2048], [4096, 4096]],
- "4:5": [[720, 900], [1080, 1350], [1440, 1800], [2160, 2700], [3072, 3840]],
-};
-
function loadPreferences(): { format: ImageFormat; quality: number } {
try {
const saved = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? "{}") as { format?: unknown; quality?: unknown };
@@ -33,7 +27,6 @@ function loadPreferences(): { format: ImageFormat; quality: number } {
} catch { return { format: "jpg", quality: DEFAULT_QUALITY }; }
}
-const sizeKey = (width: number, height: number) => `${width}x${height}`;
export function ImageExportView({ config, folderPath }: { config: ProjectConfig; folderPath: string }) {
const settingsPane = usePaneSize("export.settings", 340, { min: 280, max: 560 });
const [exporting, setExporting] = useState(false);
@@ -63,12 +56,8 @@ export function ImageExportView({ config, folderPath }: { config: ProjectConfig;
A saved image retains its authored aspect even if project settings change. */
const original = output?.width && output?.height ? { width: output.width, height: output.height } : null;
const aspectRatio = output?.imageGeneration?.aspectRatio ?? config.settings.aspectRatio;
- const sizes = [
- ...(original ? [{ ...original, value: "original", label: `${original.width} × ${original.height} (original)` }] : []),
- ...EXPORT_SIZES[aspectRatio].map(([width, height]) => ({ width, height }))
- .filter((size) => !original || sizeKey(size.width, size.height) !== sizeKey(original.width, original.height))
- .map((size) => ({ ...size, value: sizeKey(size.width, size.height), label: `${size.width} × ${size.height}` })),
- ];
+ const sizes = exportSizeChoices(original, aspectRatio, "original")
+ .map((size, index) => original && index === 0 ? { ...size, value: "original" } : size);
const [chosenSize, setChosenSize] = useState<string | null>(null);
const size = sizes.find((candidate) => candidate.value === chosenSize) ?? sizes[0];
diff --git a/src/lib/export.test.ts b/src/lib/export.test.ts
index b0e0129..00fc905 100644
--- a/src/lib/export.test.ts
+++ b/src/lib/export.test.ts
@@ -6,9 +6,11 @@ import {
clipVisualSettings,
defaultExportSettings,
estimatedBytes,
+ exportSizeChoices,
fitRect,
formatBytes,
formatDuration,
+ OUTPUT_CODECS,
generationDimensions,
outputDimensions,
resolutionLabel,
@@ -20,7 +22,7 @@ import {
type ExportSegment,
type ExportSettings,
} from "./export";
-import { createProjectConfig, IMAGE_RESOLUTIONS, LEGACY_RESOLUTIONS, PROJECT_RESOLUTIONS, type ProjectAsset, type ProjectConfig, type TimelineClip } from "./project";
+import { createProjectConfig, LEGACY_RESOLUTIONS, PROJECT_RESOLUTIONS, type ProjectAsset, type ProjectConfig, type TimelineClip } from "./project";
const asset = (id: string, overrides: Partial<ProjectAsset> = {}): ProjectAsset => ({
id,
@@ -67,7 +69,7 @@ function project(clips: TimelineClip[], assets: ProjectAsset[], overrides: Parti
}
const settings = (overrides: Partial<ExportSettings> = {}): ExportSettings => ({
- resolution: "1080p", frameRate: 30, codec: "h264", quality: "balanced", ...overrides,
+ width: 1920, height: 1080, frameRate: 30, codec: "h264", quality: "balanced", ...overrides,
});
const clipSegments = (segments: ExportSegment[]) => segments.flatMap((segment) => (segment.kind === "clip" ? [segment] : []));
@@ -102,6 +104,20 @@ describe("effect compositing", () => {
});
describe("output geometry", () => {
+ it("offers an export its own size first, then the standard sizes that differ", () => {
+ expect(exportSizeChoices({ width: 1920, height: 1080 }, "16:9", "project").map((size) => size.label))
+ .toEqual(["1920 × 1080 (project)", "1280 × 720", "2560 × 1440", "3840 × 2160"]);
+ expect(exportSizeChoices(null, "4:5", "original").map((size) => size.value)).toEqual(["720x900", "1080x1350", "1440x1800", "2160x2700", "3072x3840"]);
+ });
+
+ it("asks H.264 for a level that holds the frame, past 4K UHD too", () => {
+ const h264 = OUTPUT_CODECS.find((codec) => codec.id === "h264")!;
+ expect(h264.candidates(1920, 1080, 30)[0]).toBe("avc1.640028");
+ expect(h264.candidates(3840, 2160, 60)[0]).toBe("avc1.640034");
+ expect(h264.candidates(4096, 4096, 30)[0]).toBe("avc1.64003c");
+ expect(h264.candidates(3072, 3840, 60)[0]).toBe("avc1.64003c");
+ });
+
it("offers the widescreen sizes MiniMax H3 actually generates at", () => {
// The ladder, verbatim. These are not 16:9 rounded off — 2432×1344 is 1.810
// against 16:9's 1.778 — so they are pinned here rather than recomputed by
@@ -113,13 +129,15 @@ describe("output geometry", () => {
{ width: 1376, height: 768 },
{ width: 1920, height: 1088 },
{ width: 2432, height: 1344 },
+ { width: 2720, height: 1536 },
+ { width: 3648, height: 2048 },
]);
});
it("keeps both edges on a multiple of 32 in every shape a project can be", () => {
// The whole point of the ladder: a frame the engine cannot generate is a
// frame the project would have to rescale to fill.
- for (const resolution of IMAGE_RESOLUTIONS) {
+ for (const resolution of PROJECT_RESOLUTIONS) {
for (const ratio of ["16:9", "9:16", "1:1", "4:5"] as const) {
const { width, height } = outputDimensions(resolution, ratio);
expect({ resolution, ratio, width: width % 32, height: height % 32 })
@@ -133,7 +151,7 @@ describe("output geometry", () => {
expect(outputDimensions("768p", "9:16")).toEqual({ width: 768, height: 1376 });
expect(outputDimensions("768p", "1:1")).toEqual({ width: 768, height: 768 });
expect(outputDimensions("768p", "4:5")).toEqual({ width: 768, height: 960 });
- for (const resolution of IMAGE_RESOLUTIONS) {
+ for (const resolution of PROJECT_RESOLUTIONS) {
const wide = outputDimensions(resolution, "16:9");
expect(outputDimensions(resolution, "9:16")).toEqual({ width: wide.height, height: wide.width });
expect(outputDimensions(resolution, "1:1")).toEqual({ width: wide.height, height: wide.height });
@@ -160,7 +178,7 @@ describe("output geometry", () => {
});
it("never produces an odd edge, which a 4:2:0 encoder refuses", () => {
- for (const resolution of [...IMAGE_RESOLUTIONS, ...LEGACY_RESOLUTIONS]) {
+ for (const resolution of [...PROJECT_RESOLUTIONS, ...LEGACY_RESOLUTIONS]) {
for (const ratio of ["16:9", "9:16", "1:1", "4:5"] as const) {
const { width, height } = outputDimensions(resolution, ratio);
expect(width % 2).toBe(0);
@@ -189,7 +207,7 @@ describe("output geometry", () => {
describe("defaults", () => {
it("starts from the project's own settings instead of inventing numbers", () => {
const config = project([], [], { resolution: "4k", frameRate: 60 });
- expect(defaultExportSettings(config)).toEqual({ resolution: "4k", frameRate: 60, codec: "h264", quality: "balanced" });
+ expect(defaultExportSettings(config)).toEqual({ width: 3840, height: 2160, frameRate: 60, codec: "h264", quality: "balanced" });
});
it("derives the bitrate from the frame size and rate", () => {
diff --git a/src/lib/export.ts b/src/lib/export.ts
index 533db4e..21627f7 100644
--- a/src/lib/export.ts
+++ b/src/lib/export.ts
@@ -33,7 +33,9 @@ export type OutputCodecId = "h264" | "vp9" | "av1";
export type QualityId = "draft" | "balanced" | "high";
export interface ExportSettings {
- resolution: Resolution;
+ /** The encoded frame, in pixels: the project's own size or a standard one. */
+ width: number;
+ height: number;
frameRate: FrameRate;
codec: OutputCodecId;
quality: QualityId;
@@ -100,7 +102,11 @@ function avcLevel(width: number, height: number, frameRate: number): string {
if (macroblocks <= 8192 && rate <= 245_760) return "28"; // 4.0
if (macroblocks <= 8704 && rate <= 522_240) return "2a"; // 4.2
if (macroblocks <= 22_080 && rate <= 589_824) return "33"; // 5.1
- return "34"; // 5.2
+ if (macroblocks <= 36_864 && rate <= 2_073_600) return "34"; // 5.2
+ // 6.x: frames past 4K UHD, such as 4096×4096 or 3072×3840.
+ if (macroblocks <= 139_264 && rate <= 4_177_920) return "3c"; // 6.0
+ if (macroblocks <= 139_264 && rate <= 8_355_840) return "3d"; // 6.1
+ return "3e"; // 6.2
}
export const OUTPUT_CODECS: readonly OutputCodec[] = [
@@ -215,11 +221,35 @@ export function resolutionLabel(resolution: Resolution, aspectRatio: AspectRatio
return `${width} × ${height}`;
}
+/* The sizes an export offers besides the project's own: the standard delivery
+ sizes at each aspect, at its exact ratio. The generation ladder above is on a
+ 32-pixel grid, which is what the model needs and not what a player or a
+ platform expects — so an export may leave it. */
+export const STANDARD_EXPORT_SIZES: Record<AspectRatio, readonly (readonly [number, number])[]> = {
+ "16:9": [[1280, 720], [1920, 1080], [2560, 1440], [3840, 2160]],
+ "9:16": [[720, 1280], [1080, 1920], [1440, 2560], [2160, 3840]],
+ "1:1": [[512, 512], [1024, 1024], [1080, 1080], [2048, 2048], [4096, 4096]],
+ "4:5": [[720, 900], [1080, 1350], [1440, 1800], [2160, 2700], [3072, 3840]],
+};
+
+export const exportSizeKey = (width: number, height: number) => `${width}x${height}`;
+
+/** The Resolution choices of an export: `own` (the project's or the image's
+ * size, named by `ownLabel`) first, then every standard size that differs. */
+export function exportSizeChoices(own: { width: number; height: number } | null, aspectRatio: AspectRatio, ownLabel: string) {
+ return [
+ ...(own ? [{ ...own, value: exportSizeKey(own.width, own.height), label: `${own.width} × ${own.height} (${ownLabel})` }] : []),
+ ...STANDARD_EXPORT_SIZES[aspectRatio].map(([width, height]) => ({ width, height }))
+ .filter((size) => !own || exportSizeKey(size.width, size.height) !== exportSizeKey(own.width, own.height))
+ .map((size) => ({ ...size, value: exportSizeKey(size.width, size.height), label: `${size.width} × ${size.height}` })),
+ ];
+}
+
/** The export starts as the project already describes itself. Nothing here is
* invented: resolution and frame rate are the project's own settings. */
export function defaultExportSettings(config: ProjectConfig): ExportSettings {
return {
- resolution: config.settings.resolution,
+ ...outputDimensions(config.settings.resolution, config.settings.aspectRatio),
frameRate: config.settings.frameRate,
codec: "h264",
quality: "balanced",
@@ -452,7 +482,7 @@ export function videoDurationMs(config: ProjectConfig): number {
}
export function buildExportPlan(config: ProjectConfig, settings: ExportSettings): ExportPlan {
- const { width, height } = outputDimensions(settings.resolution, config.settings.aspectRatio);
+ const { width, height } = settings;
const frameRate = settings.frameRate;
const tracks = config.timeline.tracks;
const videoTracks = tracks.filter((track) => track.kind === "video");
diff --git a/src/lib/project.test.ts b/src/lib/project.test.ts
index 2531e10..ef8c446 100644
--- a/src/lib/project.test.ts
+++ b/src/lib/project.test.ts
@@ -27,7 +27,7 @@ import {
roundClipTransform,
seedProjectWorkspace,
LEGACY_RESOLUTIONS,
- IMAGE_RESOLUTIONS,
+ PROJECT_RESOLUTIONS,
STORY_TRACK_ID,
usableImageReferences,
usableReferenceImages,
@@ -740,7 +740,7 @@ describe("the frame sizes a project can be", () => {
names. They have to agree in BOTH directions: Rust writes the settings
file before the frontend ever parses it, so a name Rust accepts and zod
refuses is saved and then fails to open (see CLAUDE.md). */
- expect(resolutionSchema.options).toEqual([...IMAGE_RESOLUTIONS, ...LEGACY_RESOLUTIONS]);
+ expect(resolutionSchema.options).toEqual([...PROJECT_RESOLUTIONS, ...LEGACY_RESOLUTIONS]);
expect(resolutionSchema.options).toEqual([
"416p", "544p", "640p", "768p", "1088p", "1344p", "1536p", "2048p", "720p", "1080p", "4k",
]);
diff --git a/src/lib/project.ts b/src/lib/project.ts
index f6be2ca..4e44bb4 100644
--- a/src/lib/project.ts
+++ b/src/lib/project.ts
@@ -128,10 +128,7 @@ export const aspectRatioSchema = z.enum(["16:9", "9:16", "1:1", "4:5"]);
* wide and 768×1376 tall. `outputDimensions` in export.ts holds the pixels
* themselves; a test pins the two lists together so neither can grow a member
* the other has never heard of. */
-export const PROJECT_RESOLUTIONS = ["416p", "544p", "640p", "768p", "1088p", "1344p"] as const;
-
-/** Still images offer two larger sizes, also aligned to the 32-pixel grid. */
-export const IMAGE_RESOLUTIONS = [...PROJECT_RESOLUTIONS, "1536p", "2048p"] as const;
+export const PROJECT_RESOLUTIONS = ["416p", "544p", "640p", "768p", "1088p", "1344p", "1536p", "2048p"] as const;
/** Names still on disk, from before the ladder was rebuilt on multiples of 32.
* They keep their exact old pixels (1080p is still 1920×1080) and they are not
@@ -139,7 +136,7 @@ export const IMAGE_RESOLUTIONS = [...PROJECT_RESOLUTIONS, "1536p", "2048p"] as c
* back, and 1080 is not a multiple of 32. */
export const LEGACY_RESOLUTIONS = ["720p", "1080p", "4k"] as const;
-export const resolutionSchema = z.enum([...IMAGE_RESOLUTIONS, ...LEGACY_RESOLUTIONS]);
+export const resolutionSchema = z.enum([...PROJECT_RESOLUTIONS, ...LEGACY_RESOLUTIONS]);
export const imageGenerationSnapshotSchema = z.object({
scene: imageSceneSchema,