From c8ebef026bdefd18ee54a7e31c4c6b8ce9eff91b Mon Sep 17 00:00:00 2001 From: Hemkesh Date: Wed, 4 Mar 2026 21:48:47 -0600 Subject: [PATCH] Add "Native" aspect ratio option to export at cropped video dimensions Adds a "Native" option to the aspect ratio dropdown that uses the cropped video's actual aspect ratio, so the video fills the entire frame with no background visible. Selecting Native also sets padding to 0 automatically. Co-Authored-By: Claude Opus 4.6 --- src/components/video-editor/VideoEditor.tsx | 13 +++++++--- src/components/video-editor/VideoPlayback.tsx | 4 +-- src/utils/aspectRatioUtils.ts | 25 +++++++++++++++---- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/components/video-editor/VideoEditor.tsx b/src/components/video-editor/VideoEditor.tsx index 769e88e..9666c33 100644 --- a/src/components/video-editor/VideoEditor.tsx +++ b/src/components/video-editor/VideoEditor.tsx @@ -42,7 +42,7 @@ import { type PlaybackSpeed, } from "./types"; import { VideoExporter, GifExporter, type ExportProgress, type ExportQuality, type ExportSettings, type ExportFormat, type GifFrameRate, type GifSizePreset, GIF_SIZE_PRESETS, calculateOutputDimensions } from "@/lib/exporter"; -import { type AspectRatio, getAspectRatioValue } from "@/utils/aspectRatioUtils"; +import { type AspectRatio, getAspectRatioValue, getNativeAspectRatioValue } from "@/utils/aspectRatioUtils"; import { getAssetPath } from "@/lib/assetPath"; import { useShortcuts } from "@/contexts/ShortcutsContext"; import { matchesShortcut } from "@/lib/shortcuts"; @@ -833,9 +833,11 @@ export default function VideoEditor() { videoPlaybackRef.current?.pause(); } - const aspectRatioValue = getAspectRatioValue(aspectRatio); const sourceWidth = video.videoWidth || 1920; const sourceHeight = video.videoHeight || 1080; + const aspectRatioValue = aspectRatio === 'native' + ? getNativeAspectRatioValue(sourceWidth, sourceHeight, cropRegion) + : getAspectRatioValue(aspectRatio); // Get preview CONTAINER dimensions for scaling const playbackRef = videoPlaybackRef.current; @@ -1130,7 +1132,7 @@ export default function VideoEditor() {
{/* Video preview */}
-
+
{ + setAspectRatio(ratio); + if (ratio === 'native') setPadding(0); + }} />
diff --git a/src/components/video-editor/VideoPlayback.tsx b/src/components/video-editor/VideoPlayback.tsx index 2801f1a..7ca784c 100644 --- a/src/components/video-editor/VideoPlayback.tsx +++ b/src/components/video-editor/VideoPlayback.tsx @@ -11,7 +11,7 @@ import { updateOverlayIndicator } from "./videoPlayback/overlayUtils"; import { layoutVideoContent as layoutVideoContentUtil } from "./videoPlayback/layoutUtils"; import { applyZoomTransform } from "./videoPlayback/zoomTransform"; import { createVideoEventHandlers } from "./videoPlayback/videoEventHandlers"; -import { type AspectRatio, formatAspectRatioForCSS } from "@/utils/aspectRatioUtils"; +import { type AspectRatio, formatAspectRatioForCSS, getNativeAspectRatioValue } from "@/utils/aspectRatioUtils"; import { AnnotationOverlay } from "./AnnotationOverlay"; interface VideoPlaybackProps { @@ -797,7 +797,7 @@ const VideoPlayback = forwardRef(({ : { background: resolvedWallpaper || '' }; return ( -
+
{/* Background layer - always render as DOM element with blur */}