zzarcon / video-snapshot

Get snapshots from a video file in the browser :movie_camera: :sunrise:

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Get snapshots from a video file in the browser :movie_camera: :sunrise:

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

License:MIT License


Languages

Language:TypeScript 98.0%Language:HTML 2.0%