Skip to content

🎥 Make videos programmatically with React

fix getVideoMetadata() failing on videos that are fine

Jonny Burger1b4620c781be
diff --git a/packages/media-utils/src/get-video-metadata.ts b/packages/media-utils/src/get-video-metadata.ts
index 2d0274b429..0698f03c9f 100644
--- a/packages/media-utils/src/get-video-metadata.ts
+++ b/packages/media-utils/src/get-video-metadata.ts
@@ -23,14 +23,14 @@ const fn = (src: string): Promise<VideoMetadata> => {
cleanup();
};
- const pixels = video.videoHeight * video.videoWidth;
+ const onLoadedMetadata = () => {
+ const pixels = video.videoHeight * video.videoWidth;
- if (pixels === 0) {
- reject(new Error('Unable to determine video metadata'));
- return;
- }
+ if (pixels === 0) {
+ reject(new Error('Unable to determine video metadata'));
+ return;
+ }
- const onLoadedMetadata = () => {
const metadata: VideoMetadata = {
durationInSeconds: video.duration,
width: video.videoWidth,