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
// Pure crop-draft helpers for Edit Clip. The modal stores the rectangle as
// frame fractions (0–1), not rounded integer percents.
export interface CropDraft {
x: number;
y: number;
width: number;
height: number;
}
export function cropDraftFromRegion(region: CropDraft): CropDraft {
return { x: region.x, y: region.y, width: region.width, height: region.height };
}
export function cropDraftToPct(draft: CropDraft): { x: number; y: number; w: number; h: number } {
return {
x: draft.x * 100,
y: draft.y * 100,
w: draft.width * 100,
h: draft.height * 100,
};
}
export const PREVIEW_MAX_HEIGHT_PX = 360;
/**
* Preview box for the crop overlay. The crop rectangle and every drag are
* measured against THIS element, while the <video> inside it letterboxes via
* object-fit: contain — so the box must have the video's own aspect ratio or
* the overlay drifts off the pixels it claims to crop (the old fixed
* 409x230 box was 16:9 for exactly this reason). Width is therefore derived
* from the height cap and the aspect: `min(100%, height-cap * aspect)`.
* Declaring width this way — rather than `width: 100%` plus a max-height —
* matters because when a max-height clamps an aspect-ratio box, CSS keeps
* the width and BREAKS the ratio, which would letterbox portrait sources
* all over again.
*/
export function previewBoxStyle(videoAspectRatio: number): {
position: "relative";
width: string;
aspectRatio: string;
margin: string;
flexShrink: number;
background: string;
borderRadius: string;
border: string;
overflow: "hidden";
} {
const aspect =
Number.isFinite(videoAspectRatio) && videoAspectRatio > 0 ? videoAspectRatio : 16 / 9;
return {
position: "relative",
width: `min(100%, calc(${PREVIEW_MAX_HEIGHT_PX}px * ${aspect}))`,
aspectRatio: `${aspect}`,
margin: "0 auto 14px",
flexShrink: 0,
background: "#0a0b0e",
borderRadius: "var(--r-md)",
border: "1px solid var(--border)",
overflow: "hidden",
};
}