vidvid-info

Fetch info of a video

Usage no npm install needed!

<script type="module">
  import vidvidInfo from 'https://cdn.skypack.dev/vidvid-info';
</script>

README

Fetch info of a video

Fetch the duration, height and width of a video.

Installing

vidvid-info is an ES module meant to be used in browsers.

vidvid = import('https://unpkg.com/vidvid-info?module')

Usage

vidvid = import('https://unpkg.com/vidvid-info?module')

const src =
  'https://archive.org/download/BigBuckBunny_124/Content/big_buck_bunny_720p_surround.mp4'

await vidvid.info(src)
//=> {duration: 596.503219, videoHeight: 360, videoWidth: 640}

await vidvid.info(src, { timeout: 10 })
//=> Timed out in 10ms.

API

# vidvid.info(src[, options]) ยท Source, Examples

Fetches the video metadata at the specified src URL. It returns a Promise that resolves an Object with the following fields:

  • duration: the video duration in seconds
  • videoHeight: the video height in px
  • videoWidth: the video width in px

It timeouts after options.timeout (in ms) or one day by default.

If options.crossOrigin is specified, CORS is used to fetch the video metadata. By default, no CORS is used.

Credits

Developed for the LIRIS M2i project by Sylvain Lesage