Skip to content

fix(export): stop silently dropping audio when source track extraction fails#27

Open
davidy1402 wants to merge 1 commit into
blueberrycongee:mainfrom
davidy1402:fix/export-audio-track-extraction
Open

fix(export): stop silently dropping audio when source track extraction fails#27
davidy1402 wants to merge 1 commit into
blueberrycongee:mainfrom
davidy1402:fix/export-audio-track-extraction

Conversation

@davidy1402

Copy link
Copy Markdown

Problem

Fixes #26.

Exporting a long recording (~8 min) produced an MP4 with no audio track at all, while short clips exported fine and the editor preview played audio correctly. The source recording contains a valid mono 44.1 kHz AAC track.

Root cause: during export, audio is re-extracted from the source file via mediabunny. When both the UrlSource and the BlobSource (fetch().blob()) reads fail — which happens with large file:// sources — resolveSourceAudioTrack() logged a console warning and silently continued with a video-only export. The user only discovers the missing audio after a long, CPU-intensive export.

I verified the failure is in the fetch layer, not the file: parsing the exact same 263 MB recording with mediabunny's BufferSource from raw bytes finds the AAC track instantly.

Changes

  • New read-current-video-bytes IPC channel (main + preload + type defs): lets the renderer read the current video's bytes directly from disk through the main process. Only the already-registered currentVideoPath can be read — the renderer cannot pass arbitrary paths.
  • Third extraction fallback: resolveSourceAudioTrack() now tries UrlSourceBlobSourceBufferSource (via the new IPC channel), so audio extraction succeeds even when fetch(file://) misbehaves on large files.
  • Fail loudly instead of silently degrading: if every extraction attempt errors, the export now aborts with a clear error before frame rendering starts, instead of spending minutes producing a silent video. A source that parses fine but genuinely has no audio track still exports video-only with the existing editor.exportWarningAudioTrackUnavailable warning.
  • Regression tests for the fallback chain (5 new tests in videoExporterAudio.test.ts).

Testing

  • npx tsc --noEmit — clean
  • npx vitest --run — 169/169 tests pass
  • Built the patched app locally (npm run build:mac) and confirmed the fix ships in the bundle

🤖 Generated with Claude Code

…n fails

Exporting long recordings could produce a video-only MP4: audio is
re-extracted from the source file via mediabunny, and when both the
UrlSource and BlobSource reads failed (which happens with large
file:// sources), the exporter logged a console warning and silently
continued without audio. The user only found out after a long export.

- Add a read-current-video-bytes IPC channel so the renderer can read
  the source bytes directly from disk through the main process, and
  use it as a third BufferSource fallback for audio extraction.
- Fail the export with a clear error before frame rendering starts if
  every extraction attempt errors, instead of silently degrading.
  A source that parses fine but has no audio track still exports
  video-only with the existing warning.
- Add regression tests for the fallback chain.

Fixes blueberrycongee#26

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant