mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 04:38:33 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user