Coder Social home page Coder Social logo

zzarcon / video-snapshot Goto Github PK

View Code? Open in Web Editor NEW
87.0 3.0 17.0 34.74 MB

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

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

License: MIT License

HTML 1.98% TypeScript 98.02%
video canvas browser capture snapshot screenshot preview thumbnail

video-snapshot's Introduction

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

video-snapshot's People

Contributors

fghilini avatar fredguile avatar xiaoyuhen avatar zzarcon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

video-snapshot's Issues

Failed to set the 'currentTime' property

When specifying the time as a CustomVideoTime (ie, 'middle'), the error TypeError: Failed to set the 'currentTime' property on 'HTMLMediaElement': The provided double value is non-finite. is thrown.

The cause of this seems to be that video.currentTime is NaN. A quick bit of digging suggests that awaiting for the onloadedmetadata event on the video element before obtaining the current time might solve it.

Propose Logo

Hi @zzarcon ,, I made a logo for your project. What do you think? If you need to make some change please let me know. Thank you.
video snapshot
Idea : Camera, screenshot and play icon.
Best regard. Mirza Zulfan

Allow to specify time of the snapshot

const videoSnapper = new VideoSnapshot(videoFile);

videoSnapper.takeSnapshot(100); // Will return image from 100 second

videoSnapper.takeSnapshot('middle'); // Convenient value
videoSnapper.takeSnapshot('end'); // Convenient value

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.