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
fix(captions): default the insets to what actually sits well with the padding
EtienneLescot329b522ef4f8
diff --git a/src/lib/ai-edition/captions/captions.test.ts b/src/lib/ai-edition/captions/captions.test.tsindex 15ba27f9b..ce3d4a961 100644--- a/src/lib/ai-edition/captions/captions.test.ts+++ b/src/lib/ai-edition/captions/captions.test.ts@@ -7,6 +7,7 @@ import {captionBoxRect,captionSafeColumn,DEFAULT_CAPTION_SETTINGS,+ defaultCaptionInsetX,defaultCaptionInsetY,getCaptionSettings,patchCaptionSettings,@@ -233,8 +234,12 @@ describe("caption safe column", () => {});it("defaults a vertical export well clear of the platform chrome", () => {- // 5% on a 9:16 export puts the caption under the Reels/TikTok profile row.- expect(defaultCaptionInsetY(LANDSCAPE)).toBe(5);+ // The landscape values are eyeballed against the editor's default padding; the+ // portrait one answers a different question — TikTok/Reels/Shorts draw their own+ // chrome over the bottom eighth of a 9:16 export, so the same 1.5% would put the+ // caption behind a UI.+ expect(defaultCaptionInsetY(LANDSCAPE)).toBe(1.5);+ expect(defaultCaptionInsetX(LANDSCAPE)).toBe(10);expect(defaultCaptionInsetY(PORTRAIT)).toBeGreaterThan(10);});});@@ -295,7 +300,8 @@ describe("migrating a pre-anchor document", () => {});it("gives a document with no caption settings the aspect-appropriate default", () => {- expect(getCaptionSettings(doc(), LANDSCAPE).insetY).toBe(5);+ expect(getCaptionSettings(doc(), LANDSCAPE).insetY).toBe(1.5);+ expect(getCaptionSettings(doc(), LANDSCAPE).insetX).toBe(10);expect(getCaptionSettings(doc(), PORTRAIT).insetY).toBe(12.5);});@@ -308,7 +314,7 @@ describe("migrating a pre-anchor document", () => {const first = patchCaptionSettings(doc(), { enabled: true }, PORTRAIT);const stored = (first.legacyEditor as { captions: CaptionSettings }).captions;expect(stored.insetY).toBe(12.5);- expect(stored.insetX).toBe(captionSafeColumn(PORTRAIT).x);+ expect(stored.insetX).toBe(defaultCaptionInsetX(PORTRAIT));// And it stays: a later patch reads what is stored rather than re-deriving.const later = patchCaptionSettings(first, { fontSize: 60 }, PORTRAIT);diff --git a/src/lib/ai-edition/captions/index.ts b/src/lib/ai-edition/captions/index.tsindex ea5a58413..f827d62c0 100644--- a/src/lib/ai-edition/captions/index.ts+++ b/src/lib/ai-edition/captions/index.ts@@ -21,6 +21,7 @@ export {captionBoxRect,captionSafeColumn,DEFAULT_CAPTION_SETTINGS,+ defaultCaptionInsetX,defaultCaptionInsetY,getCaptionSettings,patchCaptionSettings,diff --git a/src/lib/ai-edition/captions/settings.ts b/src/lib/ai-edition/captions/settings.tsindex 1e776833f..e50d2e9c1 100644--- a/src/lib/ai-edition/captions/settings.ts+++ b/src/lib/ai-edition/captions/settings.ts@@ -97,11 +97,12 @@ export const DEFAULT_CAPTION_SETTINGS: CaptionSettings = {backgroundColor: "#000000",backgroundOpacity: 0.55,anchorV: "bottom",- // Overridden per output aspect on first read (`defaultCaptionInsetY`); this is the- // landscape value, and the one a document keeps once anything has been written.- insetY: 5,+ // Overridden per output aspect on first read (`defaultCaptionInsetY` /+ // `defaultCaptionInsetX`); these are the landscape values, and the ones a document+ // keeps once anything has been written.+ insetY: 1.5,anchorH: "center",- insetX: 16,+ insetX: 10,minWordsPerLine: 2,maxWordsPerLine: 7,};@@ -159,12 +160,27 @@ export function captionSafeColumn(aspectValue: number): { x: number; width: numbreturn aspectValue >= CAPTION_LANDSCAPE_ASPECT ? { x: 16, width: 68 } : { x: 5, width: 90 };}-/** Default distance from the anchored edge, in % of frame height, for a given output- * aspect. BBC puts the lowest line at a 5% inset; vertical formats need much more,- * because the bottom eighth of a 9:16 export is where TikTok, Reels and Shorts draw- * their own chrome over the video. */+/** Default distance from the anchored edge, in % of frame height.+ *+ * The landscape value is picked against the editor's DEFAULT PADDING rather than from+ * a broadcast spec: the footage sits inset inside the frame, so a caption a hair off+ * the frame edge lands where the eye expects it *relative to the picture*. It was+ * chosen by looking at a 16:9 export.+ *+ * Vertical keeps a much larger inset, and for an unrelated reason: the bottom eighth+ * of a 9:16 export is where TikTok, Reels and Shorts draw their own chrome over the+ * video, so a caption sitting a hair off that edge is a caption behind a UI. Nobody+ * has eyeballed this one — it is the conservative value, and the slider is right+ * there if it proves wrong. */export function defaultCaptionInsetY(aspectValue: number): number {- return aspectValue >= CAPTION_LANDSCAPE_ASPECT ? 5 : 12.5;+ return aspectValue >= CAPTION_LANDSCAPE_ASPECT ? 1.5 : 12.5;+}++/** Default distance for the horizontal anchor, in % of frame width. Same source as the+ * landscape `insetY`: it matches the default padding, not the safe column's own margin,+ * which is why it is stated here rather than borrowed from `captionSafeColumn`. */+export function defaultCaptionInsetX(aspectValue: number): number {+ return aspectValue >= CAPTION_LANDSCAPE_ASPECT ? 10 : 5;}/** Upper bound for the vertical inset, in % of the frame. 50 puts the anchored edge@@ -400,7 +416,7 @@ export function getCaptionSettings(const raw = storedCaptions(doc);const d = DEFAULT_CAPTION_SETTINGS;const defaultInsetY = defaultCaptionInsetY(aspectValue);- if (!raw) return { ...d, insetY: defaultInsetY, insetX: captionSafeColumn(aspectValue).x };+ if (!raw) return { ...d, insetY: defaultInsetY, insetX: defaultCaptionInsetX(aspectValue) };const minWords = Math.round(readNumber(raw.minWordsPerLine, d.minWordsPerLine, 1, 12));const maxWords = Math.round(readNumber(raw.maxWordsPerLine, d.maxWordsPerLine, 1, 12));@@ -416,7 +432,7 @@ export function getCaptionSettings(anchorH: readEnum(raw.anchorH, ANCHORS_H, legacy?.anchorH ?? d.anchorH),insetX: readNumber(raw.insetX,- legacy?.insetX ?? captionSafeColumn(aspectValue).x,+ legacy?.insetX ?? defaultCaptionInsetX(aspectValue),0,CAPTION_INSET_X_MAX,),