1.0.22 • Published 3 years ago

video-metadata-thumbnails v1.0.22

Weekly downloads
570
License
MIT
Repository
github
Last release
3 years ago

Convenience method(or Video object) to get metadata and thumbnails of HTML5 video Blob.

English | 简体中文

Environment Support

  • Microsoft Edge
  • Google Chrome
  • Safari(Not perfect)
    • need to wait for the video to finish playing
    • can't use all parameters
  • Firfox(Not perfect)
    • need to wait for the video to finish playing
    • can't use all parameters

EdgeChromeSafariFirefox
last 2 versionslast 2 versionslast 2 versionslast 2 versions

Installation

npm install --save video-metadata-thumbnails

or

yarn add video-metadata-thumbnails

Usage

getMetadata method & getThumbnails method

​ Add video-metadata-thumbnails.iife.js to your document and get the metadata or thumbnails value of the promise returned by then:

<input type="file" onchange="onChange(this.files)" />
<script src="https://cdn.jsdelivr.net/npm/video-metadata-thumbnails/lib/video-metadata-thumbnails.iife.js"></script>
<script>
function onChange(files) {
  __video_metadata_thumbnails__.getMetadata(files[0]).then(function(metadata) {
    console.log('Metadata: ', metadata);
  })
  __video_metadata_thumbnails__.getThumbnails(files[0]).then(function(thumbnails) {
    console.log('Thumbnails: ', thumbnails);
  })
}
</script>

​ Alternatively, you can import(or require) video-metadata-thumbnails by getting it from npm :

import { getMetadata, getThumbnails } from 'video-metadata-thumbnails';
  
const metadata = await getMetadata(blob);
const thumbnails = await getThumbnails(blob, {
  quality: 0.6
});
console.log('Metadata: ', metadata);
console.log('Thumbnails: ', thumbnails);

Video Object

​ Import(or require) video-metadata-thumbnails by getting it from npm

import { Video } from 'video-metadata-thumbnails';

const video = new Video(blob);
console.log('Metadata:', await video.getMetadata());
console.log('Thumbnails:', await video.getThumbnails({
  quality: 0.6
}))

Thumbnails' Options

  • quality
    • type: number
    • default: 0.7
    • description: video thumbnails' quality
  • interval
    • type: number
    • default: 1
    • description: time interval
  • scale
    • type: number
    • default: 0.7
    • description: video thumbnails' scale
  • start
    • type: number
    • default: 0
    • description: start frame
  • end
    • type: number
    • default: 0
    • description: the end of frame

Example

Example Online

⚠️ Notice

Blob object is required in browser.

License

Software License

Copyright (c) 2020-present, Weiwei Wang

1.0.22

3 years ago

1.0.21

3 years ago

1.0.19

3 years ago

1.0.20

3 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago