Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(audio): unblock voiceover recording and restore the left-edge trim

Ola Adebayod4c8d26d0cf9
diff --git a/electron/ai-edition/document-service.test.ts b/electron/ai-edition/document-service.test.ts
index 0aeb18a28..bf3d12289 100644
--- a/electron/ai-edition/document-service.test.ts
+++ b/electron/ai-edition/document-service.test.ts
@@ -314,6 +314,21 @@ describe("DocumentService", () => {
).rejects.toBeInstanceOf(ProjectFileError);
});
+ it("accepts a recorded .webm take as audio", async () => {
+ // MediaRecorder writes a voiceover as webm/opus — the same extension a
+ // screen recording uses. The caller has already declared the kind here,
+ // so this gate must take it; only the import PICKER, which has nothing
+ // but the extension to go on, still refuses .webm as audio.
+ const doc = await service.createProject("P");
+ const next = await service.addAsset(doc.project.id, {
+ path: "/tmp/voiceover-2026.webm",
+ kind: "audio",
+ });
+ expect(next.assets.at(-1)).toMatchObject({ kind: "audio" });
+ // ...and it must not have claimed the primary (video-only) slot.
+ expect(next.project.primaryAssetId).toBeUndefined();
+ });
+
it("accepts a video extension under the default kind but not as audio", async () => {
const doc = await service.createProject("P");
// The same extension routing works in reverse: an .mp3 is fine as audio
diff --git a/electron/ai-edition/document-service.ts b/electron/ai-edition/document-service.ts
index cf471e4df..9c9b958b9 100644
--- a/electron/ai-edition/document-service.ts
+++ b/electron/ai-edition/document-service.ts
@@ -78,6 +78,15 @@ function isSupportedVideoPath(filePath: string): boolean {
// Imported audio (issue #350). Decoding is handled downstream by the same
// WebCodecs / ffmpeg paths that read a video's audio track, so this list is the
// container formats decodeAudioData and the compositor can open.
+// What may be filed as an AUDIO asset. Deliberately WIDER than the import
+// picker's list in `electron/ipc/handlers.ts`: this gate runs when the caller
+// has already declared `kind: "audio"`, so it only has to reject files that
+// could not carry audio at all, whereas the picker has to guess from the
+// extension alone and must not offer a video as audio.
+//
+// `.webm` is exactly that difference. An in-editor voiceover take is written by
+// MediaRecorder as webm/opus — the same extension a screen recording uses — so
+// the picker rightly refuses it while this gate must accept it.
const SUPPORTED_AUDIO_EXTENSIONS = new Set([
".mp3",
".wav",
@@ -85,7 +94,9 @@ const SUPPORTED_AUDIO_EXTENSIONS = new Set([
".aac",
".flac",
".ogg",
+ ".oga",
".opus",
+ ".webm",
]);
function isSupportedAudioPath(filePath: string): boolean {
diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.ts
index da90759ee..f404daa84 100644
--- a/electron/ipc/handlers.ts
+++ b/electron/ipc/handlers.ts
@@ -191,7 +191,9 @@ function hasAllowedImportVideoExtension(filePath: string): boolean {
// Imported audio (issue #350). Kept separate from the video set so the two
// pickers stay honest — an audio picker must not approve a video path and vice
-// versa. Mirrors SUPPORTED_AUDIO_EXTENSIONS in the document service.
+// versa. A SUBSET of SUPPORTED_AUDIO_EXTENSIONS in the document service, which
+// also accepts `.webm`: that gate is told the kind by its caller, while this one
+// only has the extension to go on and `.webm` is far more often a video.
const ALLOWED_IMPORT_AUDIO_EXTENSIONS = new Set([
".mp3",
".wav",
diff --git a/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx b/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx
index 0dbd1afd5..dbd0d6466 100644
--- a/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx
+++ b/src/components/ai-edition/v4/V4Timeline.geometry.test.tsx
@@ -369,7 +369,7 @@ describe("V4Timeline audio lane drag", () => {
function renderAudio() {
const placeAudioTrack = vi.fn(
- async (_id: string, _span: { startMs: number; endMs: number }) => {
+ async (_id: string, _span: { startMs: number; endMs: number; offsetMs?: number }) => {
/* the drag only awaits it */
},
);
@@ -432,6 +432,35 @@ describe("V4Timeline audio lane drag", () => {
expect((placement.endMs - placement.startMs) / 1000).toBeCloseTo(60, 3);
});
+ it("left-handle drag trims into the source instead of sliding the audio", () => {
+ // A left-edge drag is a trim IN: the head moves right by N seconds and the
+ // same N is skipped in the file, so what plays under the pill stays put.
+ // Committing the span alone left `offsetMs` untouched, which just slid the
+ // whole track along — the "my music starts five seconds late" symptom.
+ const { pill, placeAudioTrack } = renderAudio();
+ const handle = pill.firstElementChild as Element;
+ fireEvent.pointerDown(handle, { clientX: 0 });
+ window.dispatchEvent(new MouseEvent("pointermove", { clientX: 15 }));
+ window.dispatchEvent(new MouseEvent("pointerup", { clientX: 15 }));
+ expect(placeAudioTrack).toHaveBeenCalledTimes(1);
+ const [, placement] = placeAudioTrack.mock.calls[0];
+ const movedSec = placement.startMs / 1000 - 100;
+ expect(movedSec).toBeGreaterThan(0);
+ // The head moved and the source in-point advanced by the same amount.
+ expect((placement.offsetMs ?? 0) / 1000).toBeCloseTo(movedSec, 3);
+ // The tail is untouched, so the span shortens by exactly what was trimmed.
+ expect((placement.endMs - placement.startMs) / 1000).toBeCloseTo(60 - movedSec, 3);
+ });
+
+ it("a plain move leaves the source in-point alone", () => {
+ const { pill, placeAudioTrack } = renderAudio();
+ fireEvent.pointerDown(pill, { clientX: 0 });
+ window.dispatchEvent(new MouseEvent("pointermove", { clientX: 90 }));
+ window.dispatchEvent(new MouseEvent("pointerup", { clientX: 90 }));
+ const [, placement] = placeAudioTrack.mock.calls[0];
+ expect(placement.offsetMs).toBe(0);
+ });
+
it("right-handle drag pulls the out-point in, head fixed", () => {
const { pill, placeAudioTrack } = renderAudio();
// The right resize handle is the last child of the pill.
diff --git a/src/components/ai-edition/v4/V4Timeline.tsx b/src/components/ai-edition/v4/V4Timeline.tsx
index 411e27c31..bdac9ffa2 100644
--- a/src/components/ai-edition/v4/V4Timeline.tsx
+++ b/src/components/ai-edition/v4/V4Timeline.tsx
@@ -975,6 +975,10 @@ export function V4Timeline({
.placeAudioTrack(fin.id, {
startMs: Math.round(fin.start * 1000),
endMs: Math.round((fin.start + Math.max(0, fin.trimEnd - fin.trimStart)) * 1000),
+ // Carries the left-edge trim: without it the head moved but the
+ // source kept playing from the same point, so dragging the edge
+ // in just slid the audio along instead of cutting its head off.
+ offsetMs: Math.round(fin.trimStart * 1000),
})
.finally(() => {
if (audioDragRef.current === fin) {
diff --git a/src/i18n/locales/ar/timeline.json b/src/i18n/locales/ar/timeline.json
index 8afd79109..1708065ce 100644
--- a/src/i18n/locales/ar/timeline.json
+++ b/src/i18n/locales/ar/timeline.json
@@ -15,7 +15,7 @@
"pressZoom": "اضغط Z لإضافة تكبير",
"pressTrim": "اضغط T لإضافة قص",
"pressAnnotation": "اضغط A لإضافة شرح",
- "pressAudio": "اضغط M لإضافة صوت",
+ "pressAudio": "اضغط M لإضافة صوت، وV لتسجيل تعليق صوتي",
"pressSpeed": "اضغط S لإضافة سرعة",
"pressCameraFullscreen": "اضغط C لإضافة مقطع كاميرا كاملة الشاشة"
},
diff --git a/src/i18n/locales/en/timeline.json b/src/i18n/locales/en/timeline.json
index 32f92a308..4973792d7 100644
--- a/src/i18n/locales/en/timeline.json
+++ b/src/i18n/locales/en/timeline.json
@@ -15,7 +15,7 @@
"pressZoom": "Press Z to add zoom",
"pressTrim": "Press T to add trim",
"pressAnnotation": "Press A to add annotation",
- "pressAudio": "Press M to add audio",
+ "pressAudio": "Press M to add audio, V to record a voiceover",
"pressSpeed": "Press S to add speed",
"pressCameraFullscreen": "Press C to add a Full Camera segment"
},
diff --git a/src/i18n/locales/es/timeline.json b/src/i18n/locales/es/timeline.json
index 9c27f7183..8e9d301c8 100644
--- a/src/i18n/locales/es/timeline.json
+++ b/src/i18n/locales/es/timeline.json
@@ -15,7 +15,7 @@
"pressZoom": "Presiona Z para agregar zoom",
"pressTrim": "Presiona T para agregar recorte",
"pressAnnotation": "Presiona A para agregar anotación",
- "pressAudio": "Pulsa M para añadir audio",
+ "pressAudio": "Pulsa M para añadir audio, V para grabar una voz en off",
"pressSpeed": "Presiona S para agregar velocidad",
"pressCameraFullscreen": "Presiona C para agregar un segmento de cámara a pantalla completa"
},
diff --git a/src/i18n/locales/fr/timeline.json b/src/i18n/locales/fr/timeline.json
index 7bd74724e..684eb42e8 100644
--- a/src/i18n/locales/fr/timeline.json
+++ b/src/i18n/locales/fr/timeline.json
@@ -15,7 +15,7 @@
"pressZoom": "Appuyez sur Z pour ajouter un zoom",
"pressTrim": "Appuyez sur T pour ajouter une coupe",
"pressAnnotation": "Appuyez sur A pour ajouter une annotation",
- "pressAudio": "Appuyez sur M pour ajouter un audio",
+ "pressAudio": "Appuyez sur M pour ajouter un audio, V pour enregistrer une voix off",
"pressSpeed": "Appuyez sur S pour ajouter une vitesse",
"pressCameraFullscreen": "Appuyez sur C pour ajouter un segment Caméra plein écran"
},
diff --git a/src/i18n/locales/it/timeline.json b/src/i18n/locales/it/timeline.json
index 50167bc04..1fba4b1db 100644
--- a/src/i18n/locales/it/timeline.json
+++ b/src/i18n/locales/it/timeline.json
@@ -15,7 +15,7 @@
"pressZoom": "Premi Z per aggiungere zoom",
"pressTrim": "Premi T per aggiungere taglio",
"pressAnnotation": "Premi A per aggiungere annotazione",
- "pressAudio": "Premi M per aggiungere audio",
+ "pressAudio": "Premi M per aggiungere audio, V per registrare una voce fuori campo",
"pressSpeed": "Premi S per aggiungere velocità",
"pressCameraFullscreen": "Premi C per aggiungere un segmento Camera a schermo intero"
},
diff --git a/src/i18n/locales/ja-JP/timeline.json b/src/i18n/locales/ja-JP/timeline.json
index 1360da918..577dac707 100644
--- a/src/i18n/locales/ja-JP/timeline.json
+++ b/src/i18n/locales/ja-JP/timeline.json
@@ -15,7 +15,7 @@
"pressZoom": "Zキーを押してズームを追加",
"pressTrim": "Tキーを押してトリムを追加",
"pressAnnotation": "Aキーを押して注釈を追加",
- "pressAudio": "Mキーを押して音声を追加",
+ "pressAudio": "M キーで音声を追加、V キーでナレーションを録音",
"pressSpeed": "Sキーを押して再生速度を追加",
"pressCameraFullscreen": "Cキーを押してフルスクリーンカメラのセグメントを追加"
},
diff --git a/src/i18n/locales/ko-KR/timeline.json b/src/i18n/locales/ko-KR/timeline.json
index 64f39b19d..6671a922e 100644
--- a/src/i18n/locales/ko-KR/timeline.json
+++ b/src/i18n/locales/ko-KR/timeline.json
@@ -15,7 +15,7 @@
"pressZoom": "Z를 눌러 줌 추가",
"pressTrim": "T를 눌러 트림 추가",
"pressAnnotation": "A를 눌러 주석 추가",
- "pressAudio": "M을 눌러 오디오 추가",
+ "pressAudio": "M 키로 오디오 추가, V 키로 보이스오버 녹음",
"pressSpeed": "S를 눌러 속도 추가",
"pressCameraFullscreen": "C를 눌러 전체 화면 카메라 구간을 추가하세요"
},
diff --git a/src/i18n/locales/pt-BR/timeline.json b/src/i18n/locales/pt-BR/timeline.json
index b86c5511b..779ab0133 100644
--- a/src/i18n/locales/pt-BR/timeline.json
+++ b/src/i18n/locales/pt-BR/timeline.json
@@ -15,7 +15,7 @@
"pressZoom": "Pressione Z para adicionar zoom",
"pressTrim": "Pressione T para adicionar recorte",
"pressAnnotation": "Pressione A para adicionar anotação",
- "pressAudio": "Pressione M para adicionar áudio",
+ "pressAudio": "Pressione M para adicionar áudio, V para gravar uma narração",
"pressSpeed": "Pressione S para adicionar velocidade",
"pressCameraFullscreen": "Pressione C para adicionar um segmento de Câmera em Tela Cheia"
},
diff --git a/src/i18n/locales/ru/timeline.json b/src/i18n/locales/ru/timeline.json
index c8d6b4ce2..a0fa96ef9 100644
--- a/src/i18n/locales/ru/timeline.json
+++ b/src/i18n/locales/ru/timeline.json
@@ -15,7 +15,7 @@
"pressZoom": "Нажмите Z для добавления масштабирования",
"pressTrim": "Нажмите T для добавления обрезки",
"pressAnnotation": "Нажмите A для добавления аннотации",
- "pressAudio": "Нажмите M, чтобы добавить аудио",
+ "pressAudio": "Нажмите M, чтобы добавить аудио, V — чтобы записать закадровый голос",
"pressSpeed": "Нажмите S для изменения скорости",
"pressCameraFullscreen": "Нажмите C, чтобы добавить сегмент камеры на весь экран"
},
diff --git a/src/i18n/locales/tr/timeline.json b/src/i18n/locales/tr/timeline.json
index 1aaff743a..c6104fa08 100644
--- a/src/i18n/locales/tr/timeline.json
+++ b/src/i18n/locales/tr/timeline.json
@@ -15,7 +15,7 @@
"pressZoom": "Yakınlaştırma eklemek için Z tuşuna basın",
"pressTrim": "Kırpma eklemek için T tuşuna basın",
"pressAnnotation": "Açıklama eklemek için A tuşuna basın",
- "pressAudio": "Ses eklemek için M'ye basın",
+ "pressAudio": "Ses eklemek için M, seslendirme kaydetmek için V tuşuna basın",
"pressSpeed": "Hız eklemek için S tuşuna basın",
"pressCameraFullscreen": "Tam Ekran Kamera bölümü eklemek için C tuşuna basın"
},
diff --git a/src/i18n/locales/vi/timeline.json b/src/i18n/locales/vi/timeline.json
index 2cf0a1d68..340a7552d 100644
--- a/src/i18n/locales/vi/timeline.json
+++ b/src/i18n/locales/vi/timeline.json
@@ -15,7 +15,7 @@
"pressZoom": "Nhấn Z để thêm thu phóng",
"pressTrim": "Nhấn T để thêm cắt",
"pressAnnotation": "Nhấn A để thêm chú thích",
- "pressAudio": "Nhấn M để thêm âm thanh",
+ "pressAudio": "Nhấn M để thêm âm thanh, V để ghi âm lời thuyết minh",
"pressSpeed": "Nhấn S để thêm tốc độ",
"pressCameraFullscreen": "Nhấn C để thêm một đoạn Camera Toàn màn hình"
},
diff --git a/src/i18n/locales/zh-CN/timeline.json b/src/i18n/locales/zh-CN/timeline.json
index bd87fac39..6be8fe39c 100644
--- a/src/i18n/locales/zh-CN/timeline.json
+++ b/src/i18n/locales/zh-CN/timeline.json
@@ -15,7 +15,7 @@
"pressZoom": "按 Z 添加缩放",
"pressTrim": "按 T 添加剪辑",
"pressAnnotation": "按 A 添加标注",
- "pressAudio": "按 M 添加音频",
+ "pressAudio": "按 M 添加音频,按 V 录制配音",
"pressSpeed": "按 S 添加速度",
"pressCameraFullscreen": "按 C 添加一个全屏摄像头片段"
},
diff --git a/src/i18n/locales/zh-TW/timeline.json b/src/i18n/locales/zh-TW/timeline.json
index 94c99e882..f4b4d888b 100644
--- a/src/i18n/locales/zh-TW/timeline.json
+++ b/src/i18n/locales/zh-TW/timeline.json
@@ -15,7 +15,7 @@
"pressZoom": "按 Z 新增縮放",
"pressTrim": "按 T 新增剪輯",
"pressAnnotation": "按 A 新增標註",
- "pressAudio": "按 M 新增音訊",
+ "pressAudio": "按 M 新增音訊,按 V 錄製配音",
"pressSpeed": "按 S 新增速度",
"pressCameraFullscreen": "按 C 新增一個全螢幕攝影機片段"
},
diff --git a/src/lib/ai-edition/store/useTimeline.ts b/src/lib/ai-edition/store/useTimeline.ts
index f6c472492..e1c64e4c9 100644
--- a/src/lib/ai-edition/store/useTimeline.ts
+++ b/src/lib/ai-edition/store/useTimeline.ts
@@ -1349,7 +1349,7 @@ export function useTimeline() {
// track's own — `anchorAudioTrackFragments` re-derives each fragment's
// advance from the new geometry.
const placeAudioTrack = useCallback(
- async (trackId: string, span: { startMs: number; endMs: number }) => {
+ async (trackId: string, span: { startMs: number; endMs: number; offsetMs?: number }) => {
const doc = useProjectStore.getState().document;
if (!doc) return;
const others = doc.audioTracks.filter((t) => trackGroupId(t) !== trackId);
@@ -1361,6 +1361,12 @@ export function useTimeline() {
...pill,
startMs: Math.max(0, Math.round(span.startMs)),
endMs: Math.max(Math.round(span.startMs) + 1, Math.round(span.endMs)),
+ // A left-edge drag is a trim IN: the head moves right and the same
+ // amount is skipped in the source, so the audio under the pill stays
+ // put instead of sliding with it. Omitted by a plain move, which
+ // keeps the offset it already had.
+ offsetMs:
+ span.offsetMs === undefined ? pill.offsetMs : Math.max(0, Math.round(span.offsetMs)),
};
const fragments = anchorAudioTrackFragments(moved, doc.timeline.clips, () =>
createId("audio"),