From 6787c608897e3327b38f1b4e1f87560aefcbfc1d Mon Sep 17 00:00:00 2001 From: shrimbly Date: Tue, 3 Feb 2026 23:44:27 +1300 Subject: [PATCH] fix(quick-003): use full audio duration when videoDuration is 0 When videoDuration is 0 (unknown at call time), prepareAudioAsync was computing targetDuration as max(0.1, 0) = 0.1 seconds, truncating the audio to 100ms. Now computes the actual decoded audio duration from buffers and uses that when videoDuration <= 0. Co-Authored-By: Claude Opus 4.5 --- src/hooks/useAudioMixing.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hooks/useAudioMixing.ts b/src/hooks/useAudioMixing.ts index cb424edc..3a916077 100644 --- a/src/hooks/useAudioMixing.ts +++ b/src/hooks/useAudioMixing.ts @@ -117,7 +117,14 @@ export async function prepareAudioAsync( const sampleRate = decodedBuffers[0].sampleRate; const channels = decodedBuffers[0].numberOfChannels; - const targetDuration = Math.max(MINIMUM_AUDIO_DURATION, videoDuration); + + // Compute the total decoded audio duration from buffers + const decodedDuration = decodedBuffers.reduce((sum, buf) => sum + buf.length, 0) / sampleRate; + + // If videoDuration is 0 (unknown), use the full audio duration + const targetDuration = videoDuration > 0 + ? Math.max(MINIMUM_AUDIO_DURATION, videoDuration) + : Math.max(MINIMUM_AUDIO_DURATION, decodedDuration); const totalSamples = Math.max(1, Math.floor(targetDuration * sampleRate)); onProgress?.({ message: 'Processing audio...', progress: 60 });