From 5e123dd1bd8ebfa76b109d9a13a7e531234e6fe3 Mon Sep 17 00:00:00 2001 From: Sampson Yu Date: Sat, 28 Nov 2026 20:22:10 +0000 Subject: [PATCH 1/3] fix(dub): include original audio in MP4 exports before dubbing --- docs/dubbing/export.md | 13 +++--- .../features/dub/dub-export-panel.test.tsx | 43 ++++++++++++++++++- .../src/features/dub/dub-export-panel.tsx | 4 +- .../src/features/dub/dub-session.test.ts | 2 + .../renderer/src/features/dub/dub-session.ts | 2 +- 5 files changed, 54 insertions(+), 10 deletions(-) diff --git a/docs/dubbing/export.md b/docs/dubbing/export.md index d66e81d2c5..21edbc56f2 100644 --- a/docs/dubbing/export.md +++ b/docs/dubbing/export.md @@ -8,12 +8,13 @@ Default Track control when the source audio should play first instead. ## Exporting before a dub exists A transcribed video can be exported without generating a dub. SRT and VTT -export the transcript, or its translation when you have translated it, and -MP4 keeps the original audio; turn on **Burn subtitles into picture** to draw -the transcript onto the video. The editor's current lines are sent to the -backend first (`POST /dub/sync-transcript/{job_id}`), so your edits are -included. Once a dub exists, exports use the lines that dub was rendered from -and that call is refused. Audio-only projects still need a dub to export. +export the transcript, or its translation when you have translated it. With no +saved track selection, MP4 includes **Original** before a dub exists. Turn on +**Burn subtitles into picture** to draw the transcript onto the video. The +editor sends its current lines to the backend first +(`POST /dub/sync-transcript/{job_id}`), so your edits are included. Once a dub +exists, exports use the lines it was rendered from and that call is refused. +Audio-only projects still need a dub to export. ## Background volume diff --git a/electron/src/renderer/src/features/dub/dub-export-panel.test.tsx b/electron/src/renderer/src/features/dub/dub-export-panel.test.tsx index f9d2fa6fdb..cfa5cfd549 100644 --- a/electron/src/renderer/src/features/dub/dub-export-panel.test.tsx +++ b/electron/src/renderer/src/features/dub/dub-export-panel.test.tsx @@ -10,7 +10,10 @@ vi.mock('@/lib/api/client', () => ({ describeError: (error: unknown) => (error instanceof Error ? error.message : String(error)), errorFromResponse: vi.fn(), })); -vi.mock('./dub-session', () => ({ setDubExportPreferences: mocks.preferences })); +vi.mock('./dub-session', () => ({ + setDubExportPreferences: mocks.preferences, + recordDubSavedFile: vi.fn(), +})); vi.mock('@/components/pipeline-failure', () => ({ PipelineFailure: ({ fallback }: { fallback: string }) =>

{fallback}

, })); @@ -33,6 +36,44 @@ beforeEach(() => { }); afterEach(cleanup); +it('saves a subtitled MP4 with original audio before a dub by default', async () => { + render(); + + const save = screen.getByRole('button', { name: 'dub.flow_save' }); + expect(save).toBeEnabled(); + expect(screen.getByRole('switch', { name: 'exportModal.original' })).toBeChecked(); + fireEvent.click(save); + + await waitFor(() => expect(mocks.save).toHaveBeenCalledOnce()); + expect(mocks.api.mock.calls[0][0]).toBe('/dub/sync-transcript/job'); + expect(JSON.parse(mocks.api.mock.calls[0][1].body).segments[0].text).toBe('Edited & complete'); + const url = new URL(mocks.save.mock.calls[0][0].url, 'http://localhost'); + expect(url.pathname).toBe('/api/dub/download/job'); + expect(url.searchParams.get('include_tracks')).toBe('original'); + expect(url.searchParams.get('default_track')).toBe('original'); + expect(url.searchParams.get('burn_subs')).toBe('true'); +}); + +it('respects an explicitly excluded original track before a dub', () => { + render( + , + ); + expect(screen.getByRole('switch', { name: 'exportModal.original' })).not.toBeChecked(); + expect(screen.getByRole('button', { name: 'dub.flow_save' })).toBeDisabled(); +}); + +it('still selects dubbed audio by default when there is a generated track', () => { + render( + , + ); + expect(screen.getByRole('switch', { name: 'exportModal.original' })).not.toBeChecked(); + expect(screen.getByRole('button', { name: 'FR' })).toHaveAttribute('aria-pressed', 'true'); + expect(screen.getByRole('button', { name: 'dub.flow_save' })).toBeEnabled(); +}); + it('offers plain text before a dub, syncs the complete edited transcript and opens native Save As', async () => { render(); expect(screen.getByRole('button', { name: 'transcriptions.export_plain' })).toHaveAttribute( diff --git a/electron/src/renderer/src/features/dub/dub-export-panel.tsx b/electron/src/renderer/src/features/dub/dub-export-panel.tsx index 022536ce6f..15f9576d12 100644 --- a/electron/src/renderer/src/features/dub/dub-export-panel.tsx +++ b/electron/src/renderer/src/features/dub/dub-export-panel.tsx @@ -35,7 +35,8 @@ export function DubExportPanel({ session, disabled }: { session: DubSession; dis const setFormat = (format: DubExportFormat) => setDubExportPreferences({ format }); const trackChoice = preferences.track || ''; const setTrack = (track: string) => setDubExportPreferences({ track }); - const excluded = preferences.excluded || ['original']; + const undubbed = session.tracks.length === 0; + const excluded = preferences.excluded ?? (undubbed ? [] : ['original']); const setExcluded = (excluded: string[]) => setDubExportPreferences({ excluded }); const preserveBg = dubPreservesBackground(session); const backgroundUnavailable = session.subtitleOnly || session.separateBackground === false; @@ -59,7 +60,6 @@ export function DubExportPanel({ session, disabled }: { session: DubSession; dis const selected = tracks.filter((code) => !excluded.includes(code)); // Before any dub, the transcript still exports: as subtitles, or burned into // the original video with its own audio (#3393). - const undubbed = session.tracks.length === 0; const choices = format === 'mp4' ? selected : undubbed ? ['original'] : session.tracks; const track = choices.includes(trackChoice) ? trackChoice diff --git a/electron/src/renderer/src/features/dub/dub-session.test.ts b/electron/src/renderer/src/features/dub/dub-session.test.ts index b280d8f435..662b76c3dc 100644 --- a/electron/src/renderer/src/features/dub/dub-session.test.ts +++ b/electron/src/renderer/src/features/dub/dub-session.test.ts @@ -1584,6 +1584,8 @@ it('validates supplied subtitles before upload and skips transcription', async ( ]); expect(dubSession.state.segments[0].text).toBe('Hola'); expect(dubSession.state.phase).toBe('editing'); + expect(dubSession.state.tracks).toEqual([]); + expect(dubSession.state.exportOptions?.excluded).toBeUndefined(); }); it('does not prepare media or start ASR when supplied subtitles are invalid', async () => { diff --git a/electron/src/renderer/src/features/dub/dub-session.ts b/electron/src/renderer/src/features/dub/dub-session.ts index 50f09ab2a8..c6fca0f01f 100644 --- a/electron/src/renderer/src/features/dub/dub-session.ts +++ b/electron/src/renderer/src/features/dub/dub-session.ts @@ -1634,7 +1634,7 @@ export async function uploadDub( skipTranscription: Boolean(subtitles), separateBackground: options?.separateBackground !== false, narrationWanted: options?.narrationWanted === true, - exportOptions: { preserveBg: options?.separateBackground !== false, excluded: ['original'] }, + exportOptions: { preserveBg: options?.separateBackground !== false }, subtitleTargetLang: subtitleTarget, })); // An empty file has nothing to upload; the file row asks for another one. From d1051f7451d0cc9c225570fcf046b5b3567d399e Mon Sep 17 00:00:00 2001 From: debpalash <4178343+debpalash@users.noreply.github.com> Date: Sun, 29 Nov 2026 02:10:07 +0530 Subject: [PATCH 2/3] Keep automatic MP4 track selection across project reloads (cherry picked from commit 0442bcbe2626b19e0e6187d8e5c69e9010665734) --- .../src/features/projects/project-format.test.ts | 6 ++++++ .../renderer/src/features/projects/project-format.ts | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/electron/src/renderer/src/features/projects/project-format.test.ts b/electron/src/renderer/src/features/projects/project-format.test.ts index b92d63369d..ccdc4845b7 100644 --- a/electron/src/renderer/src/features/projects/project-format.test.ts +++ b/electron/src/renderer/src/features/projects/project-format.test.ts @@ -117,3 +117,9 @@ it('opens projects that only store modern export preferences', () => { const saved = projectPayload(session, 'Updated'); expect(projectSession({ id: 'saved', ...saved }, defaults).exportOptions).toMatchObject(exportOptions); }); + +it.each([{ excluded: undefined }, { excluded: [] }, { excluded: ['original'] }])('round-trips the MP4 exclusion preference $excluded', ({ excluded }) => { + const session = { ...defaults, jobId: 'job', tracks: ['fr'], exportOptions: { excluded } }; + const saved = JSON.parse(JSON.stringify(projectPayload(session, 'Dub'))); + expect(projectSession({ ...saved, id: 'job' }, defaults).exportOptions?.excluded).toEqual(excluded); +}); diff --git a/electron/src/renderer/src/features/projects/project-format.ts b/electron/src/renderer/src/features/projects/project-format.ts index a98b1ecb5d..8b8ca3d8db 100644 --- a/electron/src/renderer/src/features/projects/project-format.ts +++ b/electron/src/renderer/src/features/projects/project-format.ts @@ -112,11 +112,13 @@ export function projectPayload(session: DubSession, name: string) { burnSubs: session.exportOptions.burn, dualSubs: session.exportOptions.dual, karaokeSubs: session.exportOptions.karaoke, - exportTracks: Object.fromEntries( - ['original', ...session.tracks, ...(session.exportOptions.excluded || [])].map( - (code) => [code, !session.exportOptions?.excluded?.includes(code)], - ), - ), + exportTracks: session.exportOptions.excluded + ? Object.fromEntries( + ['original', ...session.tracks, ...session.exportOptions.excluded].map( + (code) => [code, !session.exportOptions?.excluded?.includes(code)], + ), + ) + : undefined, } : {}), fitOptions: session.fitOptions, From 9b335ea26574a15731ddac0099173cd49bdc3c1f Mon Sep 17 00:00:00 2001 From: Sampson Yu Date: Sat, 28 Nov 2026 20:47:55 +0000 Subject: [PATCH 3/3] docs(dub): add MP4 export changelog for #4524 --- changelog.d/4524.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/4524.fixed.md diff --git a/changelog.d/4524.fixed.md b/changelog.d/4524.fixed.md new file mode 100644 index 0000000000..0288c7ac8b --- /dev/null +++ b/changelog.d/4524.fixed.md @@ -0,0 +1 @@ +MP4 exports select Original by default before dubbing and retain automatic track selection when a project is reopened (#4524) — thanks @Sampsonyu and @debpalash!