fix(producer): handle no-audio stream gracefully in resolveMediaDuration

When an <audio> element referenced a file with no audio stream (e.g. a
silent screen-recording used as an audio src, or a video-only clip),
extractAudioMetadata threw "[FFmpeg] No audio stream found". The error
propagated uncaught through Promise.all in compileHtmlFile and crashed
the entire render.

Apply the same graceful-skip pattern already used for missing files and
failed downloads: catch the probe error and return { duration: 0 } so
the element is excluded from the composition without aborting the render.

Confirmed via 7 production HyperframeRenderWorkflow failures all sharing
the same TemporalMagicEditActivity.RENDER_PREVIEW stack trace.
This commit is contained in:
Miguel Ángel
2026-04-29 16:53:35 +02:00
committed by GitHub
parent eb065260dc
commit 8b234be20c
+13 -4
View File
@@ -167,10 +167,19 @@ async function resolveMediaDuration(
return { duration: 0, resolvedPath: filePath };
}
const metadata =
tagName === "video"
? await extractMediaMetadata(filePath)
: await extractAudioMetadata(filePath);
let metadata: { durationSeconds: number };
if (tagName === "video") {
metadata = await extractMediaMetadata(filePath);
} else {
try {
metadata = await extractAudioMetadata(filePath);
} catch {
// Source file has no audio stream (e.g. a silent video used as an audio src).
// Return duration 0 so the element is excluded from the composition gracefully,
// matching how missing files and failed downloads are already handled above.
return { duration: 0, resolvedPath: filePath };
}
}
const fileDuration = metadata.durationSeconds;
const effectiveDuration = fileDuration - mediaStart;