fix: keep embedded audio in legacy mac mic sidecar exports

This commit is contained in:
webadderall
2026-06-02 11:10:45 +10:00
parent 0c690bd5c2
commit 8288b8b793
2 changed files with 28 additions and 0 deletions
+22
View File
@@ -161,6 +161,28 @@ describe("AudioProcessor offline render preparation", () => {
expect(renderAndMuxOfflineAudio).toHaveBeenCalled();
});
it("avoids the single-sidecar fast path for legacy mac mic sidecars that still need embedded audio", async () => {
const processor = new AudioProcessor() as unknown as OfflineRenderTestHarness;
const loadAudioFileDemuxer = vi.spyOn(processor, "loadAudioFileDemuxer");
const renderAndMuxOfflineAudio = vi
.spyOn(processor, "renderAndMuxOfflineAudio")
.mockResolvedValue();
await processor.process(
{} as never,
{} as never,
"file:///tmp/recording.mp4",
[],
[],
undefined,
[],
["/tmp/recording.mic.m4a"],
);
expect(loadAudioFileDemuxer).not.toHaveBeenCalled();
expect(renderAndMuxOfflineAudio).toHaveBeenCalled();
});
it("soft-limits mixed peaks before encoding or WAV conversion", () => {
const samples = new Float32Array([
-1.6,
+6
View File
@@ -263,12 +263,18 @@ export class AudioProcessor {
videoUrl,
sortedSourceAudioFallbackPaths,
);
const requiresLegacyMacMicSidecarMix =
routingPolicy.includeEmbeddedInExport &&
!routingPolicy.hasEmbeddedSourceAudio &&
routingPolicy.playbackPaths.length === 1 &&
routingPolicy.playbackPaths[0]?.toLowerCase().endsWith(".mic.m4a") === true;
const hasTimedCompanionAudio = routingPolicy.playbackPaths.some(
(audioPath) => (sourceAudioFallbackStartDelayMsByPath?.[audioPath] ?? 0) > 0,
);
const needsSourceAudioMixing =
routingPolicy.playbackPaths.length > 1 ||
(routingPolicy.hasEmbeddedSourceAudio && routingPolicy.playbackPaths.length > 0) ||
requiresLegacyMacMicSidecarMix ||
hasTimedCompanionAudio;
// When speed edits, audio regions, or multiple audio sources need mixing, use offline AudioContext pipeline.