Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
revert: undo local merge of PR #347
Siddharth7169e583c739
diff --git a/src/components/video-editor/SettingsPanel.tsx b/src/components/video-editor/SettingsPanel.tsxindex 9c8086ea1..b1cd78d66 100644--- a/src/components/video-editor/SettingsPanel.tsx+++ b/src/components/video-editor/SettingsPanel.tsx@@ -354,7 +354,6 @@ export function SettingsPanel({const cropSnapshotRef = useRef<CropRegion | null>(null);const [cropAspectLocked, setCropAspectLocked] = useState(false);const [cropAspectRatio, setCropAspectRatio] = useState("");- const isPortraitCanvas = isPortraitAspectRatio(aspectRatio);const videoWidth = videoElement?.videoWidth || 1920;const videoHeight = videoElement?.videoHeight || 1080;@@ -780,17 +779,15 @@ export function SettingsPanel({<SelectValue placeholder={t("layout.selectPreset")} /></SelectTrigger><SelectContent>- {WEBCAM_LAYOUT_PRESETS.filter((preset) => {- if (preset.value === "picture-in-picture") return true;- if (preset.value === "vertical-stack") return isPortraitCanvas;- return !isPortraitCanvas;- }).map((preset) => (+ {WEBCAM_LAYOUT_PRESETS.filter(+ (preset) =>+ preset.value === "picture-in-picture" ||+ isPortraitAspectRatio(aspectRatio),+ ).map((preset) => (<SelectItem key={preset.value} value={preset.value} className="text-xs">{preset.value === "picture-in-picture"? t("layout.pictureInPicture")- : preset.value === "vertical-stack"- ? t("layout.verticalStack")- : t("layout.dualFrame")}+ : t("layout.verticalStack")}</SelectItem>))}</SelectContent>diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsxindex 0321f430d..ffe3add7a 100644--- a/src/components/video-editor/VideoEditor.tsx+++ b/src/components/video-editor/VideoEditor.tsx@@ -1884,8 +1884,7 @@ export default function VideoEditor() {pushState({aspectRatio: ar,webcamLayoutPreset:- (isPortraitAspectRatio(ar) && webcamLayoutPreset === "dual-frame") ||- (!isPortraitAspectRatio(ar) && webcamLayoutPreset === "vertical-stack")+ !isPortraitAspectRatio(ar) && webcamLayoutPreset === "vertical-stack"? "picture-in-picture": webcamLayoutPreset,})@@ -1938,7 +1937,7 @@ export default function VideoEditor() {onWebcamLayoutPresetChange={(preset) =>pushState({webcamLayoutPreset: preset,- webcamPosition: preset === "picture-in-picture" ? webcamPosition : null,+ webcamPosition: preset === "vertical-stack" ? null : webcamPosition,})}webcamMaskShape={webcamMaskShape}diff --git a/src/components/video-editor/projectPersistence.test.ts b/src/components/video-editor/projectPersistence.test.tsindex 9a99ef758..fdf5f6668 100644--- a/src/components/video-editor/projectPersistence.test.ts+++ b/src/components/video-editor/projectPersistence.test.ts@@ -44,7 +44,6 @@ describe("projectPersistence media compatibility", () => {aspectRatio: "16:9",webcamLayoutPreset: "picture-in-picture",webcamMaskShape: "circle",- webcamPosition: null,exportQuality: "good",exportFormat: "mp4",gifFrameRate: 15,@@ -67,30 +66,6 @@ describe("projectPersistence media compatibility", () => {normalizeProjectEditor({ webcamMaskShape: "not-a-real-shape" as never }).webcamMaskShape,).toBe("rectangle");});-- it("accepts the dual frame webcam layout preset", () => {- expect(normalizeProjectEditor({ webcamLayoutPreset: "dual-frame" }).webcamLayoutPreset).toBe(- "dual-frame",- );- });-- it("falls back from dual frame to picture in picture for portrait aspect ratios", () => {- expect(- normalizeProjectEditor({- aspectRatio: "9:16",- webcamLayoutPreset: "dual-frame",- }).webcamLayoutPreset,- ).toBe("picture-in-picture");- });-- it("clears webcamPosition when the normalized preset is not picture in picture", () => {- expect(- normalizeProjectEditor({- webcamLayoutPreset: "dual-frame",- webcamPosition: { cx: 0.2, cy: 0.8 },- }).webcamPosition,- ).toBeNull();- });});it("creates stable snapshots for identical project state", () => {diff --git a/src/components/video-editor/projectPersistence.ts b/src/components/video-editor/projectPersistence.tsindex a8362c8e7..ce0c751ef 100644--- a/src/components/video-editor/projectPersistence.ts+++ b/src/components/video-editor/projectPersistence.ts@@ -1,7 +1,7 @@import type { ExportFormat, ExportQuality, GifFrameRate, GifSizePreset } from "@/lib/exporter";import type { ProjectMedia } from "@/lib/recordingSession";import { normalizeProjectMedia } from "@/lib/recordingSession";-import { ASPECT_RATIOS, type AspectRatio, isPortraitAspectRatio } from "@/utils/aspectRatioUtils";+import { ASPECT_RATIOS, type AspectRatio } from "@/utils/aspectRatioUtils";import {type AnnotationRegion,type CropRegion,@@ -78,26 +78,6 @@ function isFiniteNumber(value: unknown): value is number {return typeof value === "number" && Number.isFinite(value);}-function computeNormalizedWebcamLayoutPreset(- webcamLayoutPreset: Partial<ProjectEditorState>["webcamLayoutPreset"],- normalizedAspectRatio: AspectRatio,-): WebcamLayoutPreset {- switch (webcamLayoutPreset) {- case "picture-in-picture":- return webcamLayoutPreset;- case "vertical-stack":- return isPortraitAspectRatio(normalizedAspectRatio)- ? webcamLayoutPreset- : DEFAULT_WEBCAM_LAYOUT_PRESET;- case "dual-frame":- return isPortraitAspectRatio(normalizedAspectRatio)- ? DEFAULT_WEBCAM_LAYOUT_PRESET- : webcamLayoutPreset;- default:- return DEFAULT_WEBCAM_LAYOUT_PRESET;- }-}-function clamp(value: number, min: number, max: number) {return Math.min(max, Math.max(min, value));}@@ -205,26 +185,6 @@ export function resolveProjectMedia(export function normalizeProjectEditor(editor: Partial<ProjectEditorState>): ProjectEditorState {const validAspectRatios = new Set<AspectRatio>(ASPECT_RATIOS);- const normalizedAspectRatio: AspectRatio = validAspectRatios.has(- editor.aspectRatio as AspectRatio,- )- ? (editor.aspectRatio as AspectRatio)- : "16:9";- const normalizedWebcamLayoutPreset = computeNormalizedWebcamLayoutPreset(- editor.webcamLayoutPreset,- normalizedAspectRatio,- );- const normalizedWebcamPosition: WebcamPosition | null =- normalizedWebcamLayoutPreset === "picture-in-picture" &&- editor.webcamPosition &&- typeof editor.webcamPosition === "object" &&- isFiniteNumber((editor.webcamPosition as WebcamPosition).cx) &&- isFiniteNumber((editor.webcamPosition as WebcamPosition).cy)- ? {- cx: clamp((editor.webcamPosition as WebcamPosition).cx, 0, 1),- cy: clamp((editor.webcamPosition as WebcamPosition).cy, 0, 1),- }- : DEFAULT_WEBCAM_POSITION;const normalizedZoomRegions: ZoomRegion[] = Array.isArray(editor.zoomRegions)? editor.zoomRegions@@ -436,8 +396,13 @@ export function normalizeProjectEditor(editor: Partial<ProjectEditorState>): ProtrimRegions: normalizedTrimRegions,speedRegions: normalizedSpeedRegions,annotationRegions: normalizedAnnotationRegions,- aspectRatio: normalizedAspectRatio,- webcamLayoutPreset: normalizedWebcamLayoutPreset,+ aspectRatio:+ editor.aspectRatio && validAspectRatios.has(editor.aspectRatio) ? editor.aspectRatio : "16:9",+ webcamLayoutPreset:+ editor.webcamLayoutPreset === "vertical-stack" ||+ editor.webcamLayoutPreset === "picture-in-picture"+ ? editor.webcamLayoutPreset+ : DEFAULT_WEBCAM_LAYOUT_PRESET,webcamMaskShape:editor.webcamMaskShape === "rectangle" ||editor.webcamMaskShape === "circle" ||@@ -449,7 +414,16 @@ export function normalizeProjectEditor(editor: Partial<ProjectEditorState>): Protypeof editor.webcamSizePreset === "number" && isFiniteNumber(editor.webcamSizePreset)? Math.max(10, Math.min(50, editor.webcamSizePreset)): DEFAULT_WEBCAM_SIZE_PRESET,- webcamPosition: normalizedWebcamPosition,+ webcamPosition:+ editor.webcamPosition &&+ typeof editor.webcamPosition === "object" &&+ isFiniteNumber((editor.webcamPosition as WebcamPosition).cx) &&+ isFiniteNumber((editor.webcamPosition as WebcamPosition).cy)+ ? {+ cx: clamp((editor.webcamPosition as WebcamPosition).cx, 0, 1),+ cy: clamp((editor.webcamPosition as WebcamPosition).cy, 0, 1),+ }+ : DEFAULT_WEBCAM_POSITION,exportQuality:editor.exportQuality === "medium" || editor.exportQuality === "source"? editor.exportQualitydiff --git a/src/components/video-editor/videoPlayback/layoutUtils.ts b/src/components/video-editor/videoPlayback/layoutUtils.tsindex 4b713cffc..5059ccb4f 100644--- a/src/components/video-editor/videoPlayback/layoutUtils.ts+++ b/src/components/video-editor/videoPlayback/layoutUtils.ts@@ -140,7 +140,7 @@ export function layoutVideoContent(params: LayoutParams): LayoutResult | null {screenRect.y,screenRect.width,screenRect.height,- compositeLayout.screenBorderRadius ?? (compositeLayout.screenCover ? 0 : borderRadius),+ compositeLayout.screenCover ? 0 : borderRadius,);maskGraphics.fill({ color: 0xffffff });diff --git a/src/i18n/locales/en/settings.json b/src/i18n/locales/en/settings.jsonindex f861fd555..d0559f595 100644--- a/src/i18n/locales/en/settings.json+++ b/src/i18n/locales/en/settings.json@@ -26,7 +26,6 @@"selectPreset": "Select preset","pictureInPicture": "Picture in Picture","verticalStack": "Vertical Stack",- "dualFrame": "Dual Frame","webcamShape": "Camera Shape","webcamSize": "Webcam Size"},diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.jsonindex 1a16d8430..7cfa02c88 100644--- a/src/i18n/locales/es/settings.json+++ b/src/i18n/locales/es/settings.json@@ -26,7 +26,6 @@"selectPreset": "Seleccionar predefinido","pictureInPicture": "Imagen en imagen","verticalStack": "Apilado vertical",- "dualFrame": "Marco dual","webcamShape": "Forma de cámara","webcamSize": "Tamaño de cámara"},diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.jsonindex 299483a7c..9fa87d5b5 100644--- a/src/i18n/locales/zh-CN/settings.json+++ b/src/i18n/locales/zh-CN/settings.json@@ -26,7 +26,6 @@"selectPreset": "选择预设","pictureInPicture": "画中画","verticalStack": "垂直堆叠",- "dualFrame": "双画框","webcamShape": "摄像头形状","webcamSize": "摄像头大小"},diff --git a/src/lib/compositeLayout.test.ts b/src/lib/compositeLayout.test.tsindex 596eb7558..90883b1b9 100644--- a/src/lib/compositeLayout.test.ts+++ b/src/lib/compositeLayout.test.ts@@ -169,29 +169,6 @@ describe("computeCompositeLayout", () => {expect(layout?.screenCover).toBe(true);});- it("uses a 2:1 split layout in dual frame mode", () => {- const layout = computeCompositeLayout({- canvasSize: { width: 1920, height: 1080 },- maxContentSize: { width: 1536, height: 864 },- screenSize: { width: 1920, height: 1080 },- webcamSize: { width: 1280, height: 720 },- layoutPreset: "dual-frame",- });-- expect(layout).not.toBeNull();- expect(layout?.webcamRect).not.toBeNull();- expect(layout?.screenRect.y).toBe(108);- expect(layout?.screenRect.height).toBe(864);- expect(layout?.screenBorderRadius).toBe(layout?.webcamRect?.borderRadius);- expect(layout?.webcamRect?.y).toBe(108);- expect(layout?.webcamRect?.height).toBe(864);- expect(layout?.webcamRect?.x).toBeGreaterThan(layout?.screenRect.x ?? 0);- expect(- Math.abs((layout?.screenRect.width ?? 0) - 2 * (layout?.webcamRect?.width ?? 0)),- ).toBeLessThanOrEqual(1);- expect(layout?.screenCover).toBe(true);- });-it("forces circular and square masks to use square dimensions", () => {const circularLayout = computeCompositeLayout({canvasSize: { width: 1920, height: 1080 },diff --git a/src/lib/compositeLayout.ts b/src/lib/compositeLayout.tsindex e6db73375..48583a370 100644--- a/src/lib/compositeLayout.ts+++ b/src/lib/compositeLayout.ts@@ -15,7 +15,7 @@ export interface Size {height: number;}-export type WebcamLayoutPreset = "picture-in-picture" | "vertical-stack" | "dual-frame";+export type WebcamLayoutPreset = "picture-in-picture" | "vertical-stack";/** Webcam size as a percentage of the canvas reference dimension (10–50). */export type WebcamSizePreset = number;@@ -44,17 +44,9 @@ interface StackTransform {gap: number;}-interface SplitTransform {- type: "split";- gapFraction: number;- minGap: number;- screenUnits: number;- webcamUnits: number;-}-export interface WebcamLayoutPresetDefinition {label: string;- transform: OverlayTransform | StackTransform | SplitTransform;+ transform: OverlayTransform | StackTransform;borderRadius: BorderRadiusRule;shadow: WebcamLayoutShadow | null;}@@ -62,7 +54,6 @@ export interface WebcamLayoutPresetDefinition {export interface WebcamCompositeLayout {screenRect: RenderRect;webcamRect: StyledRenderRect | null;- screenBorderRadius?: number;/** When true, the video should be scaled to cover screenRect (cropping overflow). */screenCover?: boolean;}@@ -110,22 +101,6 @@ const WEBCAM_LAYOUT_PRESET_MAP: Record<WebcamLayoutPreset, WebcamLayoutPresetDef},shadow: null,},- "dual-frame": {- label: "Dual Frame",- transform: {- type: "split",- gapFraction: 0.02,- minGap: 12,- screenUnits: 2,- webcamUnits: 1,- },- borderRadius: {- max: MAX_BORDER_RADIUS,- min: 12,- fraction: 0.06,- },- shadow: null,- },};export const WEBCAM_LAYOUT_PRESETS = Object.entries(WEBCAM_LAYOUT_PRESET_MAP).map(@@ -218,69 +193,6 @@ export function computeCompositeLayout(params: {};}- if (preset.transform.type === "split") {- const screenRect = centerRect({- canvasSize,- size: screenSize,- maxSize: maxContentSize,- });-- if (!webcamWidth || !webcamHeight || webcamWidth <= 0 || webcamHeight <= 0) {- return { screenRect, webcamRect: null };- }-- const contentWidth = Math.min(canvasWidth, Math.max(1, Math.round(maxContentSize.width)));- const contentHeight = Math.min(canvasHeight, Math.max(1, Math.round(maxContentSize.height)));- const contentX = Math.max(0, Math.floor((canvasWidth - contentWidth) / 2));- const contentY = Math.max(0, Math.floor((canvasHeight - contentHeight) / 2));- const gap = Math.max(- preset.transform.minGap,- Math.round(contentWidth * preset.transform.gapFraction),- );- const totalUnits = preset.transform.screenUnits + preset.transform.webcamUnits;- const availableWidth = Math.max(1, contentWidth - gap);- const screenSlotWidth = Math.max(- 1,- Math.round((availableWidth * preset.transform.screenUnits) / totalUnits),- );- const webcamSlotWidth = Math.max(1, availableWidth - screenSlotWidth);-- const screenSlot = {- x: contentX,- y: contentY,- width: screenSlotWidth,- height: contentHeight,- };- const webcamSlot = {- x: contentX + screenSlotWidth + gap,- y: contentY,- width: webcamSlotWidth,- height: contentHeight,- };-- const webcamBorderRadius = Math.min(- preset.borderRadius.max,- Math.max(- preset.borderRadius.min,- Math.round(Math.min(webcamSlot.width, webcamSlot.height) * preset.borderRadius.fraction),- ),- );-- return {- screenRect: screenSlot,- screenBorderRadius: webcamBorderRadius,- webcamRect: {- x: webcamSlot.x,- y: webcamSlot.y,- width: webcamSlot.width,- height: webcamSlot.height,- borderRadius: webcamBorderRadius,- maskShape: "rectangle",- },- screenCover: true,- };- }-const transform = preset.transform;const screenRect = centerRect({canvasSize,@@ -359,16 +271,7 @@ export function computeCompositeLayout(params: {function centerRect(params: { canvasSize: Size; size: Size; maxSize: Size }): RenderRect {const { canvasSize, size, maxSize } = params;- return centerRectInBounds({- bounds: { x: 0, y: 0, width: canvasSize.width, height: canvasSize.height },- size,- maxSize,- });-}--function centerRectInBounds(params: { bounds: RenderRect; size: Size; maxSize: Size }): RenderRect {- const { bounds, size, maxSize } = params;- const { x: boundsX, y: boundsY, width: boundsWidth, height: boundsHeight } = bounds;+ const { width: canvasWidth, height: canvasHeight } = canvasSize;const { width, height } = size;const { width: maxWidth, height: maxHeight } = maxSize;const scale = Math.min(maxWidth / width, maxHeight / height, 1);@@ -376,8 +279,8 @@ function centerRectInBounds(params: { bounds: RenderRect; size: Size; maxSize: Sconst resolvedHeight = Math.round(height * scale);return {- x: boundsX + Math.max(0, Math.floor((boundsWidth - resolvedWidth) / 2)),- y: boundsY + Math.max(0, Math.floor((boundsHeight - resolvedHeight) / 2)),+ x: Math.max(0, Math.floor((canvasWidth - resolvedWidth) / 2)),+ y: Math.max(0, Math.floor((canvasHeight - resolvedHeight) / 2)),width: resolvedWidth,height: resolvedHeight,};diff --git a/src/lib/exporter/frameRenderer.ts b/src/lib/exporter/frameRenderer.tsindex 3c0fd3c39..44102b44a 100644--- a/src/lib/exporter/frameRenderer.ts+++ b/src/lib/exporter/frameRenderer.ts@@ -507,12 +507,7 @@ export class FrameRenderer {const previewWidth = this.config.previewWidth || 1920;const previewHeight = this.config.previewHeight || 1080;const canvasScaleFactor = Math.min(width / previewWidth, height / previewHeight);- const scaledBorderRadius =- compositeLayout.screenBorderRadius != null- ? compositeLayout.screenBorderRadius- : compositeLayout.screenCover- ? 0- : borderRadius * canvasScaleFactor;+ const scaledBorderRadius = compositeLayout.screenCover ? 0 : borderRadius * canvasScaleFactor;this.maskGraphics.clear();this.maskGraphics.roundRect(0, 0, screenRect.width, screenRect.height, scaledBorderRadius);@@ -789,22 +784,6 @@ export class FrameRenderer {if (webcamFrame && webcamRect) {const preset = getWebcamLayoutPresetDefinition(this.config.webcamLayoutPreset);const shape = webcamRect.maskShape ?? this.config.webcamMaskShape ?? "rectangle";- const sourceWidth =- ("displayWidth" in webcamFrame && webcamFrame.displayWidth > 0- ? webcamFrame.displayWidth- : webcamFrame.codedWidth) || webcamRect.width;- const sourceHeight =- ("displayHeight" in webcamFrame && webcamFrame.displayHeight > 0- ? webcamFrame.displayHeight- : webcamFrame.codedHeight) || webcamRect.height;- const sourceAspect = sourceWidth / sourceHeight;- const targetAspect = webcamRect.width / webcamRect.height;- const sourceCropWidth =- sourceAspect > targetAspect ? Math.round(sourceHeight * targetAspect) : sourceWidth;- const sourceCropHeight =- sourceAspect > targetAspect ? sourceHeight : Math.round(sourceWidth / targetAspect);- const sourceCropX = Math.max(0, Math.round((sourceWidth - sourceCropWidth) / 2));- const sourceCropY = Math.max(0, Math.round((sourceHeight - sourceCropHeight) / 2));ctx.save();drawCanvasClipPath(ctx,@@ -826,10 +805,6 @@ export class FrameRenderer {ctx.clip();ctx.drawImage(webcamFrame as unknown as CanvasImageSource,- sourceCropX,- sourceCropY,- sourceCropWidth,- sourceCropHeight,webcamRect.x,webcamRect.y,webcamRect.width,