All Projects → pankod → canvas2video

pankod / canvas2video

Licence: GPL-3.0 License
canvas2video is a backend solution for creating and rendering dynamic videos.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to canvas2video

Werender
Simple, light-weight, Canvas library for 2D rendering
Stars: ✭ 13 (-93.3%)
Mutual labels:  canvas, rendering
Spritejs
A cross platform high-performance graphics system.
Stars: ✭ 4,712 (+2328.87%)
Mutual labels:  canvas, rendering
Wechart
Create all the [ch]arts by cax or three.js - Cax 和 three.js 创造一切图[表]
Stars: ✭ 152 (-21.65%)
Mutual labels:  canvas, rendering
Awesome Pixijs
My list of awesome pixi.js related parties
Stars: ✭ 489 (+152.06%)
Mutual labels:  canvas, rendering
Pixi.js
The HTML5 Creation Engine: Create beautiful digital content with the fastest, most flexible 2D WebGL renderer.
Stars: ✭ 34,982 (+17931.96%)
Mutual labels:  canvas, rendering
Hilo3d
Hilo3d, a WebGL Rendering Engine.
Stars: ✭ 123 (-36.6%)
Mutual labels:  canvas, rendering
Picasso
Picasso is a high quality 2D vector graphic rendering library. It support path , matrix , gradient , pattern , image and truetype font.
Stars: ✭ 205 (+5.67%)
Mutual labels:  canvas, rendering
SHSoftwareRasterizer
软光栅器的简单实现
Stars: ✭ 31 (-84.02%)
Mutual labels:  rendering
volrend
PlenOctree Volume Rendering (supports CUDA & fragment shader backends)
Stars: ✭ 419 (+115.98%)
Mutual labels:  rendering
isometric-renders
Creates high-resolution isometric screenshots of Minecraft's game objects
Stars: ✭ 42 (-78.35%)
Mutual labels:  rendering
Nabla
OpenGL/OpenGL ES/Vulkan/CUDA/OptiX Modular Rendering Framework for PC/Linux/Android
Stars: ✭ 235 (+21.13%)
Mutual labels:  rendering
ssr
React Server-Side Rendering Example
Stars: ✭ 265 (+36.6%)
Mutual labels:  rendering
obman render
[cvpr19] Code to generate images from the ObMan dataset, synthetic renderings of hands holding objects (or hands in isolation)
Stars: ✭ 61 (-68.56%)
Mutual labels:  rendering
SLProject
SLProject is a platform independent 3D computer graphics scene graph library. Read more on:
Stars: ✭ 47 (-75.77%)
Mutual labels:  rendering
video seg
视频片段提取
Stars: ✭ 14 (-92.78%)
Mutual labels:  ffmepg
prax
Experimental rendering library geared towards hybrid SSR+SPA apps. Focus on radical simplicity and performance. Tiny and dependency-free.
Stars: ✭ 18 (-90.72%)
Mutual labels:  rendering
downscale
Better image downscale with canvas.
Stars: ✭ 80 (-58.76%)
Mutual labels:  canvas
BBMOD
Advanced 3D in GameMaker
Stars: ✭ 31 (-84.02%)
Mutual labels:  rendering
rendiation
Rendiation Rendering Framework
Stars: ✭ 31 (-84.02%)
Mutual labels:  rendering
UniRate
Unity plugin to easily manage the application frame rate and rendering interval. Preventing battery power consumption and device heat, especially on mobile platforms.
Stars: ✭ 26 (-86.6%)
Mutual labels:  rendering
            

@pankod/canvas2video

Create dynamic, data-driven videos on the fly.

Maintainability Test Coverage npm version npm dependencies Status dev-dependencies Status Meercode CI Score

Created by Pankod


About

@pankod/canvas2video is a backend solution for creating and rendering dynamic videos. It lets you build web canvas scenes by using the Cairo-backed fabric library and add animations with gsap. Your animation timeline will be rendered frame by frame and piped to ffmpeg renderer for the final video output.

Use Cases

📺 Personalized video advertising

🎞️ Programmatical customization of video templates

Creating dynamic videos with real-time data (See: Weather Example - Youtube)

Getting started

To install the module, run the following in the command line:

npm install @pankod/canvas2video --save

or

yarn add @pankod/canvas2video

Usage

renderer expects a makeScene function where you create your canvas animation by using fabric and gsap methods. It returns a stream of frames to be consumed by the encoder in the next step.

Below is a basic example of a one-second rotation animation of "Hello World" text. After rendering the animation and encoding the video, the output will be saved to output/hello-world.mp4.

import { renderer, encoder } from "@pankod/canvas2video";

const helloWorld = async () => {
    const stream = await renderer({
        silent: false,
        width: 1920,
        height: 1080,
        fps: 30,
        makeScene: (fabric, canvas, anim, compose) => {
            const text = new fabric.Text("Hello world", {
                left: 400,
                top: 400,
                fontSize: 100,
                fill: "#f99339",
                angle: 0,
            });
            canvas.add(text);
            anim.to(text, {
                duration: 1,
                angle: 360,
                ease: Power3.easeOut,
            });
            compose();
        },
    });

    const output = await encoder({
        silent: false,
        frameStream: stream,
        output: "output/hello-world.mp4",
        fps: {
            input: 30,
            output: 30,
        },
        
    });
    console.log("process done,", output.path);
};

You may refer the following documentations to learn how the construct your own makeScene methods:

📃Fabric.js Documentation

📃GSAP Documentation

You can optionally provide the encoder function a backgroundVideo object. In this case, your animation will be used as an overlay layer and merged with the background video. More information about the usage of background videos is given in the Options section.

Examples


You'll find two working demos int the examples folder folder of the project. Give them a try by following the steps below:

Check out examples

$ git clone https://github.com/pankod/canvas2video.git
$ cd examples
$ npm i

After this, you can run commands at the below then check examples/output directory:

Example 1

$ npm run start:hello-world

Example 2

$ npm run start:weather

Options

Renderer

Properties Type Description
width
*required
number canvas width
height
*required
number canvas height
fps
*required
number animation fps
makeScene
*required
function See below

makeScene

The function takes 4 arguments(fabric, canvas, anim and compose) which is passed by the renderer function.

renderer({
    /* .. */
    makeScene: (fabric, canvas, anim, compose) => {
        /**
         * your code to create and manipulate your canvas
         */
    },
});
Parameter Type
fabric fabric.js instance Repo
canvas fabric.StaticCanvas Repo
anim gsap.TimelineMax Repo
compose () => void

Encoder

Properties Type Description
frameStream
*required
Readable renderer function return value
output
*required
string output file path
fps
*required
Object { input: number, output: number }
backgroundVideo Object See below

backgroundVideo

backgroundVideo: {
  videoPath: string, // your background video path
  inSeconds: number, // video start time in seconds
  outSeconds: number, // video end time in seconds
}

To-do

📌 Lottie animation support

📌 Thread & concurrency management

📌 Finer control over encoder settings

License

License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].