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(editor): address automated review findings
Vitali Gusatinsky7582a5fcd05a
diff --git a/crates/compositor/src/audio.rs b/crates/compositor/src/audio.rsindex 9a6375528..adfeb0906 100644--- a/crates/compositor/src/audio.rs+++ b/crates/compositor/src/audio.rs@@ -117,22 +117,22 @@ pub fn finish_audio(mut pcm: PlanarPcm, settings: SceneAudio) -> PlanarPcm {if shift == 0 {return pcm;}- let mut shifted = vec![vec![0.0f32; samples]; pcm.len()];if shift > 0 {let destination = (shift as usize).min(samples);let count = samples - destination;- for channel in 0..pcm.len() {- shifted[channel][destination..destination + count]- .copy_from_slice(&pcm[channel][..count]);+ for channel in pcm.iter_mut() {+ channel.copy_within(..count, destination);+ channel[..destination].fill(0.0);}} else {let source = ((-shift) as usize).min(samples);let count = samples - source;- for channel in 0..pcm.len() {- shifted[channel][..count].copy_from_slice(&pcm[channel][source..source + count]);+ for channel in pcm.iter_mut() {+ channel.copy_within(source.., 0);+ channel[count..].fill(0.0);}}- shifted+ pcm}extern "C" {diff --git a/src/components/ai-edition/VirtualPreview.audio.test.ts b/src/components/ai-edition/VirtualPreview.audio.test.tsindex cf67db989..a565aebc0 100644--- a/src/components/ai-edition/VirtualPreview.audio.test.ts+++ b/src/components/ai-edition/VirtualPreview.audio.test.ts@@ -17,4 +17,11 @@ describe("resolveAudioPreviewTime", () => {shouldPlay: false,});});++ it("plays while the duration is still unknown", () => {+ expect(resolveAudioPreviewTime(1, 0, Number.NaN)).toEqual({+ targetTimeSec: 1,+ shouldPlay: true,+ });+ });});diff --git a/src/components/ai-edition/VirtualPreview.tsx b/src/components/ai-edition/VirtualPreview.tsxindex 4af4e1e13..30bc1aa02 100644--- a/src/components/ai-edition/VirtualPreview.tsx+++ b/src/components/ai-edition/VirtualPreview.tsx@@ -53,6 +53,38 @@ export function resolveAudioPreviewTime(};}+interface PreviewAudioGraph {+ context: AudioContext;+ highpasses: BiquadFilterNode[];+ compressor: DynamicsCompressorNode;+ gain: GainNode;+}++function applyPreviewAudioSettings(+ graph: PreviewAudioGraph | null,+ elements: Array<HTMLAudioElement | null>,+ autoMaster: boolean,+ gainDb: number,+): void {+ const outputGain = 10 ** (gainDb / 20);+ if (!graph) {+ for (const element of elements) {+ if (element) element.volume = Math.min(1, outputGain);+ }+ return;+ }+ for (const filter of graph.highpasses) {+ filter.frequency.value = autoMaster ? 80 : 20;+ filter.Q.value = 0.707;+ }+ graph.compressor.threshold.value = autoMaster ? -18 : 0;+ graph.compressor.knee.value = autoMaster ? 12 : 0;+ graph.compressor.ratio.value = autoMaster ? 3 : 1;+ graph.compressor.attack.value = 0.01;+ graph.compressor.release.value = 0.12;+ graph.gain.gain.value = outputGain;+}+/** First clip (by timeline order) starting strictly after `afterTimelineStartSec` —* independent of the `clips` array's own order, which is never guaranteed to match* timeline order (a clip can be inserted/reordered at any array index; only@@ -158,12 +190,18 @@ export function VirtualPreview({const [supplementalAudioEl, setSupplementalAudioEl] = useState<HTMLAudioElement | null>(null);const [supplementalAudioSrc, setSupplementalAudioSrc] = useState<string | null>(null);const [audioProbeComplete, setAudioProbeComplete] = useState(false);- const audioGraphRef = useRef<{- context: AudioContext;- highpasses: BiquadFilterNode[];- compressor: DynamicsCompressorNode;- gain: GainNode;- } | null>(null);+ const audioSettingsRef = useRef({+ autoMaster: settings.audioAutoMaster,+ gainDb: settings.audioGainDb,+ });+ audioSettingsRef.current = {+ autoMaster: settings.audioAutoMaster,+ gainDb: settings.audioGainDb,+ };+ const audioContextRef = useRef<AudioContext | null>(null);+ const audioContextCloseTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);+ const audioSourceNodesRef = useRef(new WeakMap<HTMLAudioElement, MediaElementAudioSourceNode>());+ const audioGraphRef = useRef<PreviewAudioGraph | null>(null);const videoFrameRef = useRef<HTMLDivElement | null>(null);const isProgrammaticSeekRef = useRef(false);@@ -212,11 +250,18 @@ export function VirtualPreview({cancelled = true;};}- void window.electronAPI.preparePreviewAudioTrack(activeSource.filePath).then((result) => {- if (cancelled) return;- setSupplementalAudioSrc(result.success ? (result.path ?? null) : null);- setAudioProbeComplete(true);- });+ void window.electronAPI.preparePreviewAudioTrack(activeSource.filePath).then(+ (result) => {+ if (cancelled) return;+ setSupplementalAudioSrc(result.success ? (result.path ?? null) : null);+ setAudioProbeComplete(true);+ },+ () => {+ if (cancelled) return;+ setSupplementalAudioSrc(null);+ setAudioProbeComplete(true);+ },+ );return () => {cancelled = true;};@@ -228,54 +273,104 @@ export function VirtualPreview({useEffect(() => {if (!primaryAudioEl || !audioProbeComplete) return;if (supplementalAudioSrc && !supplementalAudioEl) return;- let context: AudioContext | null = null;+ const connectedSources: MediaElementAudioSourceNode[] = [];+ const highpasses: BiquadFilterNode[] = [];+ let compressor: DynamicsCompressorNode | null = null;+ let gain: GainNode | null = null;try {- context = new AudioContext();- const compressor = context.createDynamicsCompressor();- const gain = context.createGain();+ let context = audioContextRef.current;+ if (!context || context.state === "closed") {+ context = new AudioContext();+ audioContextRef.current = context;+ audioSourceNodesRef.current = new WeakMap();+ }+ compressor = context.createDynamicsCompressor();+ gain = context.createGain();compressor.connect(gain).connect(context.destination);- const highpasses: BiquadFilterNode[] = [];for (const element of [primaryAudioEl, supplementalAudioEl].filter((value): value is HTMLAudioElement => Boolean(value),)) {- const source = context.createMediaElementSource(element);+ let source = audioSourceNodesRef.current.get(element);+ if (!source) {+ source = context.createMediaElementSource(element);+ audioSourceNodesRef.current.set(element, source);+ }+ source.disconnect();const highpass = context.createBiquadFilter();highpass.type = "highpass";source.connect(highpass).connect(compressor);+ connectedSources.push(source);highpasses.push(highpass);}- audioGraphRef.current = { context, highpasses, compressor, gain };+ const graph = { context, highpasses, compressor, gain };+ audioGraphRef.current = graph;+ applyPreviewAudioSettings(+ graph,+ [primaryAudioEl, supplementalAudioEl],+ audioSettingsRef.current.autoMaster,+ audioSettingsRef.current.gainDb,+ );} catch {// WebAudio can be unavailable in unit tests or under a denied audio policy. The media// elements remain usable; the sync loop below still applies offset and playback state.+ for (const source of connectedSources) source.disconnect();+ for (const highpass of highpasses) highpass.disconnect();+ compressor?.disconnect();+ gain?.disconnect();+ applyPreviewAudioSettings(+ null,+ [primaryAudioEl, supplementalAudioEl],+ audioSettingsRef.current.autoMaster,+ audioSettingsRef.current.gainDb,+ );}return () => {audioGraphRef.current = null;- if (context) void context.close();+ for (const source of connectedSources) source.disconnect();+ for (const highpass of highpasses) highpass.disconnect();+ compressor?.disconnect();+ gain?.disconnect();};}, [primaryAudioEl, supplementalAudioEl, supplementalAudioSrc, audioProbeComplete]);+ // Keep one AudioContext for the component. Closing and recreating it on an effect rerun+ // permanently silences an HTMLAudioElement because createMediaElementSource may only be+ // called once for that element. Delay final cleanup by one task so React StrictMode's+ // intentional setup → cleanup → setup cycle can cancel the close and reuse the context.useEffect(() => {- const graph = audioGraphRef.current;- const outputGain = 10 ** (settings.audioGainDb / 20);- if (!graph) {- for (const element of [primaryAudioRef.current, supplementalAudioRef.current]) {- if (element) element.volume = Math.min(1, outputGain);- }- return;- }- for (const filter of graph.highpasses) {- filter.frequency.value = settings.audioAutoMaster ? 80 : 20;- filter.Q.value = 0.707;+ if (audioContextCloseTimerRef.current) {+ clearTimeout(audioContextCloseTimerRef.current);+ audioContextCloseTimerRef.current = null;}- graph.compressor.threshold.value = settings.audioAutoMaster ? -18 : 0;- graph.compressor.knee.value = settings.audioAutoMaster ? 12 : 0;- graph.compressor.ratio.value = settings.audioAutoMaster ? 3 : 1;- graph.compressor.attack.value = 0.01;- graph.compressor.release.value = 0.12;- graph.gain.gain.value = outputGain;+ return () => {+ audioContextCloseTimerRef.current = setTimeout(() => {+ audioContextCloseTimerRef.current = null;+ const context = audioContextRef.current;+ audioContextRef.current = null;+ audioSourceNodesRef.current = new WeakMap();+ if (context) void context.close();+ }, 0);+ };+ }, []);++ useEffect(() => {+ applyPreviewAudioSettings(+ audioGraphRef.current,+ [primaryAudioRef.current, supplementalAudioRef.current],+ settings.audioAutoMaster,+ settings.audioGainDb,+ );}, [settings.audioAutoMaster, settings.audioGainDb]);+ const setPrimaryAudioElement = useCallback((element: HTMLAudioElement | null) => {+ primaryAudioRef.current = element;+ setPrimaryAudioEl(element);+ }, []);+ const setSupplementalAudioElement = useCallback((element: HTMLAudioElement | null) => {+ supplementalAudioRef.current = element;+ setSupplementalAudioEl(element);+ }, []);+// ponytail: the cursor overlay wants source-media time (the recorded// cursor samples live on the original mp4 timeline, not the edited// virtual timeline). `setSourceTimeSec` is called from the 60 Hz rAF@@ -371,7 +466,8 @@ export function VirtualPreview({if (audioGraphRef.current?.context.state === "suspended") {void audioGraphRef.current.context.resume();}- void audio.play().catch(() => undefined);+ const playback = audio.play();+ if (playback) void playback.catch(() => undefined);} else if ((v.paused || !target.shouldPlay) && !audio.paused) {audio.pause();}@@ -1035,10 +1131,7 @@ export function VirtualPreview({/><audiokey={`${activeSource.id}:primary-audio`}- ref={(element) => {- primaryAudioRef.current = element;- setPrimaryAudioEl(element);- }}+ ref={setPrimaryAudioElement}src={activeSource.src}preload="metadata"aria-hidden="true"@@ -1047,10 +1140,7 @@ export function VirtualPreview({{supplementalAudioSrc ? (<audiokey={`${activeSource.id}:supplemental-audio`}- ref={(element) => {- supplementalAudioRef.current = element;- setSupplementalAudioEl(element);- }}+ ref={setSupplementalAudioElement}src={supplementalAudioSrc}preload="metadata"aria-hidden="true"diff --git a/src/components/ai-edition/v4/MediaStage.test.ts b/src/components/ai-edition/v4/MediaStage.test.tsnew file mode 100644index 000000000..fe457c243--- /dev/null+++ b/src/components/ai-edition/v4/MediaStage.test.ts@@ -0,0 +1,28 @@+import { describe, expect, it, vi } from "vitest";+import { addSelectedAssetToTimeline } from "./MediaStage";++describe("addSelectedAssetToTimeline", () => {+ it("forwards the selected asset ID and displayed fallback name", () => {+ const onAdd = vi.fn();+ const onSuccess = vi.fn();++ addSelectedAssetToTimeline(+ { id: "asset-7", label: "", originalPath: "/recordings/demo.mp4" },+ onAdd,+ onSuccess,+ );++ expect(onAdd).toHaveBeenCalledWith("asset-7");+ expect(onSuccess).toHaveBeenCalledWith("demo.mp4");+ });++ it("does nothing without a selected asset", () => {+ const onAdd = vi.fn();+ const onSuccess = vi.fn();++ addSelectedAssetToTimeline(null, onAdd, onSuccess);++ expect(onAdd).not.toHaveBeenCalled();+ expect(onSuccess).not.toHaveBeenCalled();+ });+});diff --git a/src/components/ai-edition/v4/MediaStage.tsx b/src/components/ai-edition/v4/MediaStage.tsxindex bf72f2f42..e15dc1c2e 100644--- a/src/components/ai-edition/v4/MediaStage.tsx+++ b/src/components/ai-edition/v4/MediaStage.tsx@@ -33,6 +33,16 @@ function basename(path: string): string {return path.split(/[\\/]/).pop() ?? path;}+export function addSelectedAssetToTimeline(+ selected: Pick<AxcutAsset, "id" | "label" | "originalPath"> | null,+ onAddToTimeline: (assetId: string) => void,+ onSuccess: (label: string) => void,+): void {+ if (!selected) return;+ onAddToTimeline(selected.id);+ onSuccess(selected.label || basename(selected.originalPath));+}+export function MediaStage({ onAddToTimeline }: { onAddToTimeline: (assetId: string) => void }) {const t = useScopedT("editor");const projectId = useProjectStore((s) => s.projectId);@@ -96,9 +106,9 @@ export function MediaStage({ onAddToTimeline }: { onAddToTimeline: (assetId: str};const addSelectedToTimeline = () => {- if (!selected) return;- onAddToTimeline(selected.id);- toast.success(t("mediaStage.addedToTimeline", { label: selected.label }));+ addSelectedAssetToTimeline(selected, onAddToTimeline, (label) => {+ toast.success(t("mediaStage.addedToTimeline", { label }));+ });};return (diff --git a/src/i18n/locales/ar/settings.json b/src/i18n/locales/ar/settings.jsonindex 95351aa2c..34969e119 100644--- a/src/i18n/locales/ar/settings.json+++ b/src/i18n/locales/ar/settings.json@@ -54,10 +54,10 @@"reactiveWebcamDescription": "تتقلص الكاميرا بسلاسة أثناء تكبير الفيديو حتى لا تعيق الرؤية.","help": "طريقة دمج كاميرا الويب مع الشاشة: صورة داخل صورة، أو تكديس عمودي، أو إطار مزدوج، وشكل القناع والحجم والانعكاس.","helpNoWebcam": "لا يحتوي هذا المشروع على كاميرا، لذلك فإن عناصر التحكم في التخطيط معطّلة ويعرض الإعداد المسبق «بدون كاميرا». يُحتفظ بالتخطيط المحفوظ لحين إضافة كاميرا.",- "webcamFraming": "Webcam framing",- "webcamCropZoom": "Crop zoom",- "webcamCropX": "Horizontal pan",- "webcamCropY": "Vertical pan",+ "webcamFraming": "تأطير كاميرا الويب",+ "webcamCropZoom": "تكبير الاقتصاص",+ "webcamCropX": "تحريك أفقي",+ "webcamCropY": "تحريك عمودي","shapes": {"rectangle": "مستطيل","circle": "دائرة",@@ -305,11 +305,11 @@"maxWords": "أكثر عدد كلمات في السطر"},"audio": {- "title": "Audio",- "autoMaster": "Auto master",- "syncOffset": "Sync offset",- "outputGain": "Output trim",- "reset": "Reset audio",- "help": "Automatically clean and balance voice audio, then fine-tune timing and level."+ "title": "الصوت",+ "autoMaster": "تحسين الصوت تلقائيًا",+ "syncOffset": "إزاحة المزامنة",+ "outputGain": "ضبط مستوى الإخراج",+ "reset": "إعادة ضبط الصوت",+ "help": "نظّف ووازن صوت الكلام تلقائيًا، ثم اضبط التوقيت والمستوى بدقة."}}diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.jsonindex 0445f456c..83a37016f 100644--- a/src/i18n/locales/es/settings.json+++ b/src/i18n/locales/es/settings.json@@ -54,10 +54,10 @@"reactiveWebcamDescription": "La cámara se reduce suavemente mientras el vídeo está ampliado, para no estorbar.","help": "Cómo se compone la webcam con la pantalla: imagen en imagen, pila vertical, marco doble, forma de máscara, tamaño y efecto espejo.","helpNoWebcam": "Este proyecto no tiene cámara, así que los controles de diseño están desactivados y el preajuste muestra «Sin cámara». Tu diseño guardado se conserva para cuando añadas una cámara.",- "webcamFraming": "Webcam framing",- "webcamCropZoom": "Crop zoom",- "webcamCropX": "Horizontal pan",- "webcamCropY": "Vertical pan",+ "webcamFraming": "Encuadre de cámara",+ "webcamCropZoom": "Zoom de recorte",+ "webcamCropX": "Desplazamiento horizontal",+ "webcamCropY": "Desplazamiento vertical","shapes": {"rectangle": "Rect.","circle": "Círculo",@@ -306,10 +306,10 @@},"audio": {"title": "Audio",- "autoMaster": "Auto master",- "syncOffset": "Sync offset",- "outputGain": "Output trim",- "reset": "Reset audio",- "help": "Automatically clean and balance voice audio, then fine-tune timing and level."+ "autoMaster": "Mejora automática de voz",+ "syncOffset": "Desfase de sincronización",+ "outputGain": "Ajuste de salida",+ "reset": "Restablecer audio",+ "help": "Limpia y equilibra la voz automáticamente y luego ajusta con precisión el tiempo y el nivel."}}diff --git a/src/i18n/locales/fr/settings.json b/src/i18n/locales/fr/settings.jsonindex 169c9fc1f..7079cc5a5 100644--- a/src/i18n/locales/fr/settings.json+++ b/src/i18n/locales/fr/settings.json@@ -54,10 +54,10 @@"reactiveWebcamDescription": "La caméra rétrécit doucement pendant le zoom, pour ne pas gêner.","help": "Composition de la webcam avec l'écran : incrustation, empilement vertical, double cadre, forme du masque, taille et effet miroir.","helpNoWebcam": "Ce projet n’a pas de caméra : les réglages de disposition sont désactivés et le préréglage affiche « Sans webcam ». Votre disposition enregistrée est conservée pour le jour où une caméra sera ajoutée.",- "webcamFraming": "Webcam framing",- "webcamCropZoom": "Crop zoom",- "webcamCropX": "Horizontal pan",- "webcamCropY": "Vertical pan",+ "webcamFraming": "Cadrage de la webcam",+ "webcamCropZoom": "Zoom du recadrage",+ "webcamCropX": "Déplacement horizontal",+ "webcamCropY": "Déplacement vertical","shapes": {"rectangle": "Rect.","circle": "Cercle",@@ -306,10 +306,10 @@},"audio": {"title": "Audio",- "autoMaster": "Auto master",- "syncOffset": "Sync offset",- "outputGain": "Output trim",- "reset": "Reset audio",- "help": "Automatically clean and balance voice audio, then fine-tune timing and level."+ "autoMaster": "Mastering vocal automatique",+ "syncOffset": "Décalage de synchronisation",+ "outputGain": "Niveau de sortie",+ "reset": "Réinitialiser l’audio",+ "help": "Nettoyez et équilibrez automatiquement la voix, puis ajustez précisément la synchronisation et le niveau."}}diff --git a/src/i18n/locales/it/settings.json b/src/i18n/locales/it/settings.jsonindex 2c025602e..969262eb3 100644--- a/src/i18n/locales/it/settings.json+++ b/src/i18n/locales/it/settings.json@@ -54,10 +54,10 @@"reactiveWebcamDescription": "La webcam si riduce dolcemente durante lo zoom, così non intralcia.","help": "Come la webcam viene composta con lo schermo: picture-in-picture, pila verticale, doppio riquadro, forma della maschera, dimensione e effetto specchio.","helpNoWebcam": "Questo progetto non ha una webcam, quindi i controlli di layout sono disattivati e il preset mostra «Nessuna webcam». Il layout salvato viene conservato per quando aggiungerai una webcam.",- "webcamFraming": "Webcam framing",- "webcamCropZoom": "Crop zoom",- "webcamCropX": "Horizontal pan",- "webcamCropY": "Vertical pan",+ "webcamFraming": "Inquadratura webcam",+ "webcamCropZoom": "Zoom ritaglio",+ "webcamCropX": "Spostamento orizzontale",+ "webcamCropY": "Spostamento verticale","shapes": {"rectangle": "Rett.","circle": "Cerchio",@@ -306,10 +306,10 @@},"audio": {"title": "Audio",- "autoMaster": "Auto master",- "syncOffset": "Sync offset",- "outputGain": "Output trim",- "reset": "Reset audio",- "help": "Automatically clean and balance voice audio, then fine-tune timing and level."+ "autoMaster": "Mastering vocale automatico",+ "syncOffset": "Offset sincronizzazione",+ "outputGain": "Livello di uscita",+ "reset": "Reimposta audio",+ "help": "Pulisci e bilancia automaticamente la voce, quindi regola con precisione sincronizzazione e livello."}}diff --git a/src/i18n/locales/ja-JP/settings.json b/src/i18n/locales/ja-JP/settings.jsonindex 3577cf13e..cb77c87e6 100644--- a/src/i18n/locales/ja-JP/settings.json+++ b/src/i18n/locales/ja-JP/settings.json@@ -54,10 +54,10 @@"reactiveWebcamDescription": "ズーム中はカメラがスムーズに縮小し、邪魔になりません。","help": "ウェブカメラと画面の合成方法: ピクチャインピクチャ、縦積み、デュアルフレーム、マスク形状、サイズ、左右反転。","helpNoWebcam": "このプロジェクトにはカメラがないため、レイアウトの設定は無効で、プリセットは「Webカメラなし」と表示されます。保存されたレイアウトは、カメラを追加したときのために保持されます。",- "webcamFraming": "Webcam framing",- "webcamCropZoom": "Crop zoom",- "webcamCropX": "Horizontal pan",- "webcamCropY": "Vertical pan",+ "webcamFraming": "ウェブカメラの構図",+ "webcamCropZoom": "クロップのズーム",+ "webcamCropX": "水平方向に移動",+ "webcamCropY": "垂直方向に移動","shapes": {"rectangle": "長方形","circle": "円",@@ -305,11 +305,11 @@"maxWords": "1 行の最大単語数"},"audio": {- "title": "Audio",- "autoMaster": "Auto master",- "syncOffset": "Sync offset",- "outputGain": "Output trim",- "reset": "Reset audio",- "help": "Automatically clean and balance voice audio, then fine-tune timing and level."+ "title": "オーディオ",+ "autoMaster": "音声を自動マスタリング",+ "syncOffset": "同期オフセット",+ "outputGain": "出力レベル",+ "reset": "オーディオをリセット",+ "help": "音声を自動的に整えてバランスを調整し、タイミングと音量を細かく仕上げます。"}}diff --git a/src/i18n/locales/ko-KR/settings.json b/src/i18n/locales/ko-KR/settings.jsonindex 437738b74..0b6c7eaa6 100644--- a/src/i18n/locales/ko-KR/settings.json+++ b/src/i18n/locales/ko-KR/settings.json@@ -54,10 +54,10 @@"reactiveWebcamDescription": "확대하는 동안 카메라가 부드럽게 작아져 방해되지 않습니다.","help": "웹캠과 화면을 합성하는 방식: PIP, 세로 배치, 이중 프레임, 마스크 모양, 크기, 좌우 반전.","helpNoWebcam": "이 프로젝트에는 카메라가 없어 레이아웃 설정이 비활성화되고 프리셋이 “웹캠 없음”으로 표시됩니다. 저장된 레이아웃은 카메라를 추가할 때를 위해 유지됩니다.",- "webcamFraming": "Webcam framing",- "webcamCropZoom": "Crop zoom",- "webcamCropX": "Horizontal pan",- "webcamCropY": "Vertical pan",+ "webcamFraming": "웹캠 구도",+ "webcamCropZoom": "자르기 확대",+ "webcamCropX": "가로 이동",+ "webcamCropY": "세로 이동","shapes": {"rectangle": "직사각형","circle": "원형",@@ -305,11 +305,11 @@"maxWords": "줄당 최대 단어 수"},"audio": {- "title": "Audio",- "autoMaster": "Auto master",- "syncOffset": "Sync offset",- "outputGain": "Output trim",- "reset": "Reset audio",- "help": "Automatically clean and balance voice audio, then fine-tune timing and level."+ "title": "오디오",+ "autoMaster": "음성 자동 마스터링",+ "syncOffset": "동기화 오프셋",+ "outputGain": "출력 레벨",+ "reset": "오디오 재설정",+ "help": "음성을 자동으로 정리하고 균형을 맞춘 뒤 타이밍과 레벨을 세밀하게 조정합니다."}}diff --git a/src/i18n/locales/pt-BR/settings.json b/src/i18n/locales/pt-BR/settings.jsonindex 838c0cccb..21e28eed2 100644--- a/src/i18n/locales/pt-BR/settings.json+++ b/src/i18n/locales/pt-BR/settings.json@@ -54,10 +54,10 @@"reactiveWebcamDescription": "A câmera diminui suavemente enquanto o vídeo está ampliado, para não atrapalhar.","help": "Como a webcam é composta com a tela: picture-in-picture, pilha vertical, quadro duplo, formato da máscara, tamanho e espelhamento.","helpNoWebcam": "Este projeto não tem câmera, então os controles de layout estão desativados e a predefinição mostra “Sem Webcam”. Seu layout salvo é mantido para quando você adicionar uma câmera.",- "webcamFraming": "Webcam framing",- "webcamCropZoom": "Crop zoom",- "webcamCropX": "Horizontal pan",- "webcamCropY": "Vertical pan",+ "webcamFraming": "Enquadramento da webcam",+ "webcamCropZoom": "Zoom do recorte",+ "webcamCropX": "Deslocamento horizontal",+ "webcamCropY": "Deslocamento vertical","shapes": {"rectangle": "Ret.","circle": "Círculo",@@ -305,11 +305,11 @@"maxWords": "Máx. de palavras por linha"},"audio": {- "title": "Audio",- "autoMaster": "Auto master",- "syncOffset": "Sync offset",- "outputGain": "Output trim",- "reset": "Reset audio",- "help": "Automatically clean and balance voice audio, then fine-tune timing and level."+ "title": "Áudio",+ "autoMaster": "Masterização automática de voz",+ "syncOffset": "Deslocamento de sincronização",+ "outputGain": "Nível de saída",+ "reset": "Redefinir áudio",+ "help": "Limpe e equilibre a voz automaticamente e depois ajuste com precisão o tempo e o nível."}}diff --git a/src/i18n/locales/ru/settings.json b/src/i18n/locales/ru/settings.jsonindex f61ff0001..6d11ad9be 100644--- a/src/i18n/locales/ru/settings.json+++ b/src/i18n/locales/ru/settings.json@@ -54,10 +54,10 @@"reactiveWebcamDescription": "Камера плавно уменьшается во время приближения, чтобы не мешать.","help": "Как камера совмещается с экраном: «картинка в картинке», вертикальная стопка, двойной кадр, форма маски, размер и зеркальное отражение.","helpNoWebcam": "В этом проекте нет камеры, поэтому настройки компоновки отключены, а пресет показывает «Без веб-камеры». Сохранённая компоновка останется на случай, если вы добавите камеру.",- "webcamFraming": "Webcam framing",- "webcamCropZoom": "Crop zoom",- "webcamCropX": "Horizontal pan",- "webcamCropY": "Vertical pan",+ "webcamFraming": "Кадрирование веб-камеры",+ "webcamCropZoom": "Масштаб обрезки",+ "webcamCropX": "Смещение по горизонтали",+ "webcamCropY": "Смещение по вертикали","shapes": {"rectangle": "Прямоуг.","circle": "Круг",@@ -305,11 +305,11 @@"maxWords": "Макс. слов в строке"},"audio": {- "title": "Audio",- "autoMaster": "Auto master",- "syncOffset": "Sync offset",- "outputGain": "Output trim",- "reset": "Reset audio",- "help": "Automatically clean and balance voice audio, then fine-tune timing and level."+ "title": "Аудио",+ "autoMaster": "Автоматический мастеринг голоса",+ "syncOffset": "Смещение синхронизации",+ "outputGain": "Уровень выхода",+ "reset": "Сбросить аудио",+ "help": "Автоматически очистите и сбалансируйте голос, затем точно настройте синхронизацию и уровень."}}diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.jsonindex cef53c15f..d6994dfcb 100644--- a/src/i18n/locales/tr/settings.json+++ b/src/i18n/locales/tr/settings.json@@ -54,10 +54,10 @@"reactiveWebcamDescription": "Video yakınlaştırıldığında kamera yumuşakça küçülür, böylece yoldan çekilir.","help": "Web kamerasının ekranla birleştirilme biçimi: resim içinde resim, dikey yığın, çift çerçeve, maske şekli, boyut ve aynalama.","helpNoWebcam": "Bu projede kamera yok; bu yüzden yerleşim denetimleri kapalı ve ön ayar “Web kamerası yok” gösteriyor. Kaydettiğiniz yerleşim, bir kamera eklediğinizde kullanılmak üzere korunur.",- "webcamFraming": "Webcam framing",- "webcamCropZoom": "Crop zoom",- "webcamCropX": "Horizontal pan",- "webcamCropY": "Vertical pan",+ "webcamFraming": "Webcam kadrajı",+ "webcamCropZoom": "Kırpma yakınlaştırması",+ "webcamCropX": "Yatay kaydırma",+ "webcamCropY": "Dikey kaydırma","shapes": {"rectangle": "Dikdörtgen","circle": "Daire",@@ -305,11 +305,11 @@"maxWords": "Satır başına en çok kelime"},"audio": {- "title": "Audio",- "autoMaster": "Auto master",- "syncOffset": "Sync offset",- "outputGain": "Output trim",- "reset": "Reset audio",- "help": "Automatically clean and balance voice audio, then fine-tune timing and level."+ "title": "Ses",+ "autoMaster": "Otomatik ses mastering",+ "syncOffset": "Senkronizasyon kaydırması",+ "outputGain": "Çıkış seviyesi",+ "reset": "Sesi sıfırla",+ "help": "Konuşma sesini otomatik olarak temizleyip dengeleyin, ardından zamanlama ve seviyeyi hassas biçimde ayarlayın."}}diff --git a/src/i18n/locales/vi/settings.json b/src/i18n/locales/vi/settings.jsonindex 05bce87e5..66a32b75c 100644--- a/src/i18n/locales/vi/settings.json+++ b/src/i18n/locales/vi/settings.json@@ -54,10 +54,10 @@"reactiveWebcamDescription": "Camera thu nhỏ mượt mà khi video được phóng to, để không che khuất.","help": "Cách ghép webcam với màn hình: hình trong hình, xếp dọc, khung đôi, hình dạng mặt nạ, kích thước và lật gương.","helpNoWebcam": "Dự án này không có camera nên các tùy chọn bố cục bị tắt và thiết lập sẵn hiển thị “Không có webcam”. Bố cục đã lưu của bạn vẫn được giữ lại cho khi bạn thêm camera.",- "webcamFraming": "Webcam framing",- "webcamCropZoom": "Crop zoom",- "webcamCropX": "Horizontal pan",- "webcamCropY": "Vertical pan",+ "webcamFraming": "Khung hình webcam",+ "webcamCropZoom": "Thu phóng vùng cắt",+ "webcamCropX": "Dịch chuyển ngang",+ "webcamCropY": "Dịch chuyển dọc","shapes": {"rectangle": "Chữ nhật","circle": "Tròn",@@ -305,11 +305,11 @@"maxWords": "Số từ tối đa mỗi dòng"},"audio": {- "title": "Audio",- "autoMaster": "Auto master",- "syncOffset": "Sync offset",- "outputGain": "Output trim",- "reset": "Reset audio",- "help": "Automatically clean and balance voice audio, then fine-tune timing and level."+ "title": "Âm thanh",+ "autoMaster": "Tự động hoàn thiện giọng nói",+ "syncOffset": "Độ lệch đồng bộ",+ "outputGain": "Mức đầu ra",+ "reset": "Đặt lại âm thanh",+ "help": "Tự động làm sạch và cân bằng giọng nói, sau đó tinh chỉnh thời gian và mức âm lượng."}}diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.jsonindex 78a75aa50..518091e5e 100644--- a/src/i18n/locales/zh-CN/settings.json+++ b/src/i18n/locales/zh-CN/settings.json@@ -54,10 +54,10 @@"reactiveWebcamDescription": "放大视频时摄像头会平滑缩小,以免遮挡内容。","help": "摄像头与屏幕的合成方式:画中画、垂直堆叠、双画面、遮罩形状、大小和镜像。","helpNoWebcam": "此项目没有摄像头,因此布局控件已禁用,预设显示为“无摄像头”。你保存的布局会保留,以便添加摄像头后使用。",- "webcamFraming": "Webcam framing",- "webcamCropZoom": "Crop zoom",- "webcamCropX": "Horizontal pan",- "webcamCropY": "Vertical pan",+ "webcamFraming": "摄像头构图",+ "webcamCropZoom": "裁剪缩放",+ "webcamCropX": "水平移动",+ "webcamCropY": "垂直移动","shapes": {"rectangle": "矩形","circle": "圆形",@@ -305,11 +305,11 @@"maxWords": "每行最多词数"},"audio": {- "title": "Audio",- "autoMaster": "Auto master",- "syncOffset": "Sync offset",- "outputGain": "Output trim",- "reset": "Reset audio",- "help": "Automatically clean and balance voice audio, then fine-tune timing and level."+ "title": "音频",+ "autoMaster": "自动优化人声",+ "syncOffset": "同步偏移",+ "outputGain": "输出电平",+ "reset": "重置音频",+ "help": "自动清理并平衡人声,然后精细调整时间和音量。"}}diff --git a/src/i18n/locales/zh-TW/settings.json b/src/i18n/locales/zh-TW/settings.jsonindex 0534687ec..4596c4204 100644--- a/src/i18n/locales/zh-TW/settings.json+++ b/src/i18n/locales/zh-TW/settings.json@@ -55,10 +55,10 @@"reactiveWebcamDescription": "放大影片時鏡頭會平滑縮小,以免遮擋內容。","help": "攝影機與螢幕的合成方式:子母畫面、垂直堆疊、雙畫面、遮罩形狀、大小與鏡像。","helpNoWebcam": "此專案沒有攝影機,因此版面配置控制項已停用,預設顯示為「無網路攝影機」。你儲存的版面配置會保留,以便新增攝影機後使用。",- "webcamFraming": "Webcam framing",- "webcamCropZoom": "Crop zoom",- "webcamCropX": "Horizontal pan",- "webcamCropY": "Vertical pan",+ "webcamFraming": "攝影機構圖",+ "webcamCropZoom": "裁切縮放",+ "webcamCropX": "水平移動",+ "webcamCropY": "垂直移動","shapes": {"rectangle": "矩形","circle": "圓形",@@ -306,11 +306,11 @@"maxWords": "每行最多字數"},"audio": {- "title": "Audio",- "autoMaster": "Auto master",- "syncOffset": "Sync offset",- "outputGain": "Output trim",- "reset": "Reset audio",- "help": "Automatically clean and balance voice audio, then fine-tune timing and level."+ "title": "音訊",+ "autoMaster": "自動優化人聲",+ "syncOffset": "同步偏移",+ "outputGain": "輸出音量",+ "reset": "重設音訊",+ "help": "自動清理並平衡人聲,再精細調整時間與音量。"}}diff --git a/src/lib/ai-edition/store/editorSettings.test.ts b/src/lib/ai-edition/store/editorSettings.test.tsindex e31f9fcb2..ab7ff8bd6 100644--- a/src/lib/ai-edition/store/editorSettings.test.ts+++ b/src/lib/ai-edition/store/editorSettings.test.ts@@ -143,4 +143,17 @@ describe("patchEditorSettings", () => {const snap = getEditorSettings(doc);expect(snap.webcamPosition).toEqual({ cx: 1, cy: 0 });});++ it("preserves a non-zero crop at the bottom-right edge", () => {+ const doc: AxcutDocument = {+ ...baseDoc,+ legacyEditor: { webcamCropRegion: { x: 1, y: 1, width: 0.5, height: 0.5 } },+ };++ const crop = getEditorSettings(doc).webcamCropRegion;+ expect(crop.x).toBeCloseTo(0.99);+ expect(crop.y).toBeCloseTo(0.99);+ expect(crop.width).toBeCloseTo(0.01);+ expect(crop.height).toBeCloseTo(0.01);+ });});diff --git a/src/lib/ai-edition/store/editorSettings.ts b/src/lib/ai-edition/store/editorSettings.tsindex aef27e97e..3d4f77d0d 100644--- a/src/lib/ai-edition/store/editorSettings.ts+++ b/src/lib/ai-edition/store/editorSettings.ts@@ -255,16 +255,18 @@ function normaliseWebcamPosition(value: unknown): WebcamPosition | null {};}+const MIN_CROP_SIZE = 0.01;+function normaliseCropRegion(value: unknown): CropRegion {if (!value || typeof value !== "object") return DEFAULT_CROP_REGION;const candidate = value as Record<string, unknown>;- const x = isNumber(candidate.x) ? Math.min(1, Math.max(0, candidate.x)) : 0;- const y = isNumber(candidate.y) ? Math.min(1, Math.max(0, candidate.y)) : 0;+ const x = isNumber(candidate.x) ? Math.min(1 - MIN_CROP_SIZE, Math.max(0, candidate.x)) : 0;+ const y = isNumber(candidate.y) ? Math.min(1 - MIN_CROP_SIZE, Math.max(0, candidate.y)) : 0;const width = isNumber(candidate.width)- ? Math.min(1 - x, Math.max(0.01, candidate.width))+ ? Math.min(1 - x, Math.max(MIN_CROP_SIZE, candidate.width)): 1 - x;const height = isNumber(candidate.height)- ? Math.min(1 - y, Math.max(0.01, candidate.height))+ ? Math.min(1 - y, Math.max(MIN_CROP_SIZE, candidate.height)): 1 - y;return { x, y, width, height };}