video-snapshot
TypeScript icon, indicating that this package has built-in type declarations

1.0.11 • Public • Published
Logo

video-snapshot Build Status

Get snapshots from a video file in the browser

Demo 💅

https://zzarcon.github.io/video-snapshot

Install 🚀

$ yarn add video-snapshot

Usage

import VideoSnapshot from 'video-snapshot';

document.querySelector('input[type="file"]').addEventListener('change', onChange);

const onChange = async (e) => {
  const snapshoter = new VideoSnapshot(e.target.files[0]);
  const previewSrc = await snapshoter.takeSnapshot();
  const img = document.createElement('img');

  img.src = previewSrc;

  document.body.appendChild(img);
};

Api 👀

type CustomVideoTime = 'start' | 'middle' | 'end';
type VideoTime = number | CustomVideoTime;

class VideoSnapshot {
  constructor(blob: Blob) {};
  takeSnapshot(time?: VideoTime): Promise<string>;
  end(): void;
}

Features 💸

  • Dependency free
  • 2kb size
  • Take snapshot at any time
  • You can pass smart times to easily get better previews

Author 🦄

@zzarcon

Package Sidebar

Install

npm i video-snapshot

Weekly Downloads

2,996

Version

1.0.11

License

MIT

Unpacked Size

19.8 kB

Total Files

13

Last publish

Collaborators

  • zzarcon