Giter VIP home page Giter VIP logo

video-canvas's Introduction

video-canvas

Paint video on canvas. Extra light.

gzipped size Travis build status gzipped size

video-canvas will take care of painting a video on canvas for you. In the easiest of setups, you provide a video and you get a correctly-sized self-updating canvas ready to be used.

Features:

  • It automatically starts and pauses painting with video.play() and video.pause().
  • If the video is paused or in a background tab, nothing is painted.
  • It automatically creates a canvas element from your video (optional).
  • It automatically resizes the canvas to match your video (optional).

Install

npm install --save video-canvas
var videoCanvas = require('video-canvas');
import videoCanvas from 'video-canvas';

Usage

Simple usage:

const video = document.querySelector('video');
const canvas = videoCanvas(video); // returns the <canvas> element
document.body.appendChild(canvas)
video.play();
video.pause();

Provide your own canvas:

videoCanvas(video, {
	canvas: document.querySelector('.your-own-canvas'),
});

By default, video-canvas will automatically match the canvas size to the video size, whenever that changes. If you want to prevent this behavior, pass updateSize: false

const canvas = videoCanvas(video, {
	updateSize: false
});

If you want to customize the draw call, pass your drawing function as drawCall

const canvas = videoCanvas(video, {
	drawCall: function (ctx, video) {
		ctx.drawImage(video, 0, 0, 100, 100)
	}
});

Dependencies

No dependencies.

Related

  • get-media-size: get the real size of any media: images, videos, canvas and canvas' contexts
  • iphone-inline-video: You don't need canvas to play video inline on the iPhone

License

MIT © Federico Brigante

video-canvas's People

Contributors

bfred-it avatar fregante avatar

Watchers

 avatar

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.