Skip to content

OpenReel Video - Professional browser-based video editor. Open source CapCut alternative. 100% browser-based, no installation, no cloud uploads, no watermarks.

TypeScript

fix: disable ProRes codec (not browser-supported), add smart export recommendations

Augustus Otuf56cc8b4c462
diff --git a/apps/web/src/components/editor/ExportDialog.tsx b/apps/web/src/components/editor/ExportDialog.tsx
index 97fe11c4..dc8c7655 100644
--- a/apps/web/src/components/editor/ExportDialog.tsx
+++ b/apps/web/src/components/editor/ExportDialog.tsx
@@ -26,6 +26,46 @@ interface ExportDialogProps {
onClose: () => void;
onExport: (settings: VideoExportSettings) => void;
duration?: number;
+ projectWidth?: number;
+ projectHeight?: number;
+}
+
+type AspectRatioType = "vertical" | "square" | "horizontal";
+
+function getAspectRatioType(width: number, height: number): AspectRatioType {
+ const ratio = width / height;
+ if (ratio < 0.9) return "vertical";
+ if (ratio > 1.1) return "horizontal";
+ return "square";
+}
+
+function getRecommendedPresetsForAspectRatio(
+ presets: PlatformExportPreset[],
+ aspectType: AspectRatioType,
+): PlatformExportPreset[] {
+ const aspectRatioMap: Record<string, AspectRatioType> = {
+ "9:16": "vertical",
+ "1:1": "square",
+ "16:9": "horizontal",
+ "4:5": "vertical",
+ };
+
+ return presets.filter((preset) => {
+ if (!preset.aspectRatio) return false;
+ const presetAspectType = aspectRatioMap[preset.aspectRatio];
+ return presetAspectType === aspectType;
+ });
+}
+
+function getAspectRatioLabel(aspectType: AspectRatioType): string {
+ switch (aspectType) {
+ case "vertical":
+ return "Vertical (TikTok, Reels, Shorts)";
+ case "square":
+ return "Square (Instagram Feed)";
+ case "horizontal":
+ return "Horizontal (YouTube, Twitter)";
+ }
}
const PLATFORM_ICONS: Record<string, React.ReactNode> = {
@@ -47,19 +87,25 @@ export const ExportDialog: React.FC<ExportDialogProps> = ({
onClose,
onExport,
duration = 0,
+ projectWidth = 1920,
+ projectHeight = 1080,
}) => {
const [activeTab, setActiveTab] = useState<"presets" | "custom">("presets");
- const [selectedPlatform, setSelectedPlatform] = useState<string | null>(null);
+ const [selectedPlatform, setSelectedPlatform] = useState<string | null>(
+ "recommended",
+ );
const [selectedPreset, setSelectedPreset] =
useState<PlatformExportPreset | null>(null);
const [presets, setPresets] = useState<PlatformExportPreset[]>([]);
const [platforms, setPlatforms] = useState<string[]>([]);
+ const aspectType = getAspectRatioType(projectWidth, projectHeight);
+
const [customSettings, setCustomSettings] = useState<VideoExportSettings>({
format: "mp4",
codec: "h264",
- width: 1920,
- height: 1080,
+ width: projectWidth,
+ height: projectHeight,
frameRate: 30,
bitrate: 15000,
bitrateMode: "vbr",
@@ -83,12 +129,24 @@ export const ExportDialog: React.FC<ExportDialogProps> = ({
if (isOpen) {
setPresets(exportPresetsManager.getAllPresets());
setPlatforms(exportPresetsManager.getPlatforms());
+ setSelectedPlatform("recommended");
+ setSelectedPreset(null);
}
}, [isOpen]);
- const filteredPresets = selectedPlatform
- ? presets.filter((p) => p.platform === selectedPlatform)
- : exportPresetsManager.getRecommendedPresets();
+ const recommendedForVideo = getRecommendedPresetsForAspectRatio(
+ presets,
+ aspectType,
+ );
+
+ const filteredPresets =
+ selectedPlatform === "recommended"
+ ? recommendedForVideo.length > 0
+ ? recommendedForVideo
+ : exportPresetsManager.getRecommendedPresets()
+ : selectedPlatform
+ ? presets.filter((p) => p.platform === selectedPlatform)
+ : exportPresetsManager.getRecommendedPresets();
const handleExport = useCallback(() => {
const settings =
@@ -166,16 +224,22 @@ export const ExportDialog: React.FC<ExportDialogProps> = ({
<>
<div className="w-48 border-r border-border overflow-y-auto">
<button
- onClick={() => setSelectedPlatform(null)}
- className={`w-full flex items-center gap-2 p-3 text-sm transition-colors ${
- selectedPlatform === null
+ onClick={() => setSelectedPlatform("recommended")}
+ className={`w-full flex flex-col items-start p-3 text-sm transition-colors ${
+ selectedPlatform === "recommended"
? "bg-primary/10 text-primary border-r-2 border-primary"
: "text-text-secondary hover:bg-background-tertiary"
}`}
>
- <Star size={14} />
- Recommended
+ <div className="flex items-center gap-2">
+ <Sparkles size={14} />
+ <span className="font-medium">For Your Video</span>
+ </div>
+ <span className="text-[10px] text-text-muted mt-0.5 ml-5">
+ {getAspectRatioLabel(aspectType)}
+ </span>
</button>
+ <div className="h-px bg-border my-1" />
{platforms.map((platform) => (
<button
key={platform}
diff --git a/apps/web/src/components/editor/Toolbar.tsx b/apps/web/src/components/editor/Toolbar.tsx
index dd3422bc..a47be544 100644
--- a/apps/web/src/components/editor/Toolbar.tsx
+++ b/apps/web/src/components/editor/Toolbar.tsx
@@ -848,6 +848,8 @@ export const Toolbar: React.FC = () => {
onClose={() => setIsExportDialogOpen(false)}
onExport={handleCustomExport}
duration={project.timeline?.duration ?? 0}
+ projectWidth={project.settings?.width ?? 1920}
+ projectHeight={project.settings?.height ?? 1080}
/>
<ScreenRecorder
diff --git a/packages/core/src/export/export-engine.ts b/packages/core/src/export/export-engine.ts
index a6569830..045c9c48 100644
--- a/packages/core/src/export/export-engine.ts
+++ b/packages/core/src/export/export-engine.ts
@@ -231,43 +231,37 @@ export class ExportEngine {
},
};
+ if (fullSettings.codec === "prores") {
+ console.warn(
+ `[ExportEngine] ProRes encoding is not supported in browsers. Switching to H.264 high quality.`,
+ );
+ fullSettings.codec = "h264";
+ fullSettings.format = "mp4";
+ fullSettings.bitrate = 25000;
+ fullSettings.quality = 95;
+ }
+
const pixelCount = fullSettings.width * fullSettings.height;
- const isProRes = fullSettings.codec === "prores";
const isMemoryIntensiveCodec =
fullSettings.codec === "vp9" ||
fullSettings.codec === "av1" ||
- fullSettings.codec === "h265" ||
- isProRes;
- const maxSafePixels = isProRes
- ? 1280 * 720
- : isMemoryIntensiveCodec
- ? 1920 * 1080
- : 3840 * 2160;
+ fullSettings.codec === "h265";
+ const maxSafePixels = isMemoryIntensiveCodec ? 1920 * 1080 : 3840 * 2160;
if (pixelCount > maxSafePixels && isMemoryIntensiveCodec) {
- const maxDimension = isProRes ? 1280 : 1920;
console.warn(
- `[ExportEngine] ${fullSettings.codec.toUpperCase()} at ${fullSettings.width}x${fullSettings.height} may cause browser instability. Reducing for stability.`,
+ `[ExportEngine] ${fullSettings.codec.toUpperCase()} at ${fullSettings.width}x${fullSettings.height} may cause browser instability. Reducing to 1080p for stability.`,
);
const aspectRatio = fullSettings.width / fullSettings.height;
if (aspectRatio > 1) {
- fullSettings.width = maxDimension;
- fullSettings.height = Math.round(maxDimension / aspectRatio);
+ fullSettings.width = 1920;
+ fullSettings.height = Math.round(1920 / aspectRatio);
} else {
- fullSettings.height = maxDimension;
- fullSettings.width = Math.round(maxDimension * aspectRatio);
+ fullSettings.height = 1920;
+ fullSettings.width = Math.round(1920 * aspectRatio);
}
fullSettings.width = Math.round(fullSettings.width / 2) * 2;
fullSettings.height = Math.round(fullSettings.height / 2) * 2;
-
- if (isProRes) {
- fullSettings.codec = "h264";
- fullSettings.format = "mp4";
- fullSettings.bitrate = 20000;
- console.warn(
- `[ExportEngine] ProRes not supported in browser at this resolution. Switching to H.264 at ${fullSettings.width}x${fullSettings.height}.`,
- );
- }
}
this.abortController = new AbortController();
@@ -374,8 +368,7 @@ export class ExportEngine {
const isIntensiveCodec =
fullSettings.codec === "vp9" ||
fullSettings.codec === "av1" ||
- fullSettings.codec === "h265" ||
- fullSettings.codec === "prores";
+ fullSettings.codec === "h265";
const flushInterval = isIntensiveCodec ? 10 : 30;
for (let frame = 0; frame < totalFrames; frame++) {