Skip to content

🎥 Make videos programmatically with React

`@remotion/media-utils`: Throw if duration is `Infinity`

Jonny Burgerb16f5b4e576f
diff --git a/packages/media-utils/src/get-video-metadata.ts b/packages/media-utils/src/get-video-metadata.ts
index 2a31187914..83c6f1e8e6 100644
--- a/packages/media-utils/src/get-video-metadata.ts
+++ b/packages/media-utils/src/get-video-metadata.ts
@@ -38,6 +38,15 @@ const fn = (src: string): Promise<VideoMetadata> => {
return;
}
+ if (!Number.isFinite(video.duration)) {
+ reject(
+ new Error(
+ `Unable to determine video duration for ${src} - got Infinity. Re-encoding this video may fix this issue.`,
+ ),
+ );
+ return;
+ }
+
const metadata: VideoMetadata = {
durationInSeconds: video.duration,
width: video.videoWidth,