From 9083b30d925376d115571419a573f0fdf5bfa290 Mon Sep 17 00:00:00 2001 From: shrimbly Date: Tue, 3 Feb 2026 23:21:27 +1300 Subject: [PATCH] fix(quick-003): preserve audio MIME type for prepareAudioAsync - Extract MIME type from data URL header when fetch() Blob loses it - Create new Blob with correct type for MediaBunny format detection - Fix both executeWorkflow and regenerateNode videoStitch paths --- src/store/workflowStore.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/store/workflowStore.ts b/src/store/workflowStore.ts index 1894a6d1..5c35ce98 100644 --- a/src/store/workflowStore.ts +++ b/src/store/workflowStore.ts @@ -1913,9 +1913,13 @@ export const useWorkflowStore = create((set, get) => ({ let audioData = null; if (inputs.audio.length > 0 && inputs.audio[0]) { const { prepareAudioAsync } = await import('@/hooks/useAudioMixing'); - const audioBlob = await fetch(inputs.audio[0]).then((r) => r.blob()); - // Calculate total video duration from blobs (we'll use MediaBunny for this during stitch) - // For now, pass 0 and let stitch handle duration + const audioUrl = inputs.audio[0]; + const audioResponse = await fetch(audioUrl); + const rawBlob = await audioResponse.blob(); + // Ensure the blob has the correct MIME type for MediaBunny format detection + // Data URLs from AudioInput preserve the original MIME type, but fetch() may lose it + const audioMime = rawBlob.type || (audioUrl.startsWith('data:') ? audioUrl.split(';')[0].split(':')[1] : 'audio/mpeg'); + const audioBlob = rawBlob.type ? rawBlob : new Blob([rawBlob], { type: audioMime }); audioData = await prepareAudioAsync(audioBlob, 0); } @@ -2609,7 +2613,12 @@ export const useWorkflowStore = create((set, get) => ({ let audioData = null; if (inputs.audio.length > 0 && inputs.audio[0]) { const { prepareAudioAsync } = await import('@/hooks/useAudioMixing'); - const audioBlob = await fetch(inputs.audio[0]).then((r) => r.blob()); + const audioUrl = inputs.audio[0]; + const audioResponse = await fetch(audioUrl); + const rawBlob = await audioResponse.blob(); + // Ensure the blob has the correct MIME type for MediaBunny format detection + const audioMime = rawBlob.type || (audioUrl.startsWith('data:') ? audioUrl.split(';')[0].split(':')[1] : 'audio/mpeg'); + const audioBlob = rawBlob.type ? rawBlob : new Blob([rawBlob], { type: audioMime }); audioData = await prepareAudioAsync(audioBlob, 0); }