getVideoMetadata()
Part of the @remotion/media-utils package of helper functions.
Takes a src to a video, loads it and returns metadata for the specified source.
Arguments
src
A string pointing to an asset.
Return value
Promise<VideoMetadata> - object with information about the video data:
durationInSeconds:numberThe duration of the video in seconds.width:numberThe width of the video in pixels.height:numberThe height of the video in pixels.aspectRatio:numberVideo width divided by video height.isRemote:booleanWhether the video was imported locally or from a different origin.
Example
tsximport {getVideoMetadata } from "@remotion/media-utils";importvideo from "../video.mp4";awaitgetVideoMetadata (video ); /* {durationInSeconds: 100.00,width: 1280,height: 720,aspectRatio: 1.77777778,isRemote: false} */awaitgetVideoMetadata ("https://example.com/remote-audio.webm"); /* {durationInSeconds: 40.213,width: 1920,height: 1080,aspectRatio: 1.77777778,isRemote: true} */
tsximport {getVideoMetadata } from "@remotion/media-utils";importvideo from "../video.mp4";awaitgetVideoMetadata (video ); /* {durationInSeconds: 100.00,width: 1280,height: 720,aspectRatio: 1.77777778,isRemote: false} */awaitgetVideoMetadata ("https://example.com/remote-audio.webm"); /* {durationInSeconds: 40.213,width: 1920,height: 1080,aspectRatio: 1.77777778,isRemote: true} */
Caching behavior
This function is memoizing the results it returns.
If you pass in the same argument to src multiple times, it will return a cached version from the second time on, regardless of if the file has changed. To clear the cache, you have to reload the page.