# withmove

> Create dynamic, data-driven videos on the fly.

Latest version **0.0.2** (published 2022-05-30) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install withmove
pnpm add withmove
yarn add withmove
bun add withmove
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2022-05-30 |
| First published | 2022-05-29 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 13.4 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | SH9351 |
| Maintainers | sh9351 |

## Links

- npm: https://www.npmjs.com/package/withmove
- Repository: https://github.com/sh9351/withmove
- Homepage: https://github.com/sh9351/withmove#readme
- Issues: https://github.com/sh9351/withmove/issues
- npm.io page: https://npm.io/package/withmove

## Dependencies (6)

- [gsap](https://npm.io/package/gsap.md) ^3.10.4
- [fabric](https://npm.io/package/fabric.md) ^4.1.0
- [cli-progress](https://npm.io/package/cli-progress.md) ^3.8.2
- [ffmpeg-static](https://npm.io/package/ffmpeg-static.md) ^4.2.7
- [fluent-ffmpeg](https://npm.io/package/fluent-ffmpeg.md) ^2.1.2
- [ffprobe-static](https://npm.io/package/ffprobe-static.md) ^3.0.0

## Recent versions

- 0.0.2 (latest) — 2022-05-30
- 0.0.1 — 2022-05-29

## README

<div align="center"><h1>Withmove</h1><h3>Create dynamic, data-driven videos on the fly.</h3><img alt="npm" src="https://img.shields.io/npm/v/withmove?style=for-the-badge"><img alt="npm" src="https://img.shields.io/npm/dw/withmove?style=for-the-badge"><img alt="npm" src="https://img.shields.io/npm/l/withmove?style=for-the-badge"><img alt="npm" src="https://img.shields.io/badge/FROM-%40pankod%2Fcanvas2video-red?style=for-the-badge"><img alt="Maintenance" src="https://img.shields.io/maintenance/yes/2022?style=for-the-badge"></div>

## About
### Withmove is a **fork of [@pankod/canvas2video](https://www.npmjs.com/package/@pankod/canvas2video)**
Withmove is a simple package capable of creating mp4 videos, directly on Node.js. The core is based on @pankod/canvas2video but with additional features. **The package is currently at version 0.0.1, being very unstable and is not recommended for production use.**

## Use Cases

📺 Personalized video advertising

🎞️ Programmatical customization of video templates

⛅ Creating dynamic videos with real-time data

## Getting Started
To install the module, run the following in the command line:
`npm i withmove`

## Example
```js
const withmove = require('withmove')

withmove({
    silent: false,
    output: 'hello-world.mp4',
    fps: {
        input: 30,
        output: 30,
    },
}, {
    width: 1920,
    height: 1080,
    fps: 30,
    silent: false
}, (prop, fabric, canvas, anim) => {
    prop(fabric.Text, 'Hello world!', {
        from: {
            left: -100,
            top: 0,
            fontFamily: 'Arial',
            fontWeight: 'Bold',
            fontSize: 100,
            fill: 'white',
        },
        to: {
            duration: 1,
            left: 0,
            ease: 'power1.in' // ease from gsap
        }
    })
}).then(() => console.log('Video successfully rendered'))

```
## Usage
`withmove` itself is a function(promise), expecting three arguments: 2 config objects and 1 callback function. The first argument is the `config` for the **encoder** while the second argument being for the **renderer.** The two config objects are documented below. The callback function will be called with four arguments: `prop`, `fabric`, `canvas` and `anim`. Basic usage of `prop` is explaind below:
```js
prop(fabric.Text, 'Hello world!', {
        from: {
            left: -100,
            top: 0,
            fontFamily: 'Arial',
            fontWeight: 'Bold',
            fontSize: 100,
            fill: 'white',
        },
        to: {
            duration: 1,
            left: 0,
            ease: 'power1.in'
        }
    })
```
With `prop`, you can add new objects directly to the `canvas`. The first argument is from `fabric`, and the `new` keyword is not required. The second argument is the main argument, which will be directly passed to your `fabric` class. The third, also the last argument is the `config` argument, which allows you to set specific configs and also animate easily. Without animations, you may also use as the following:
```js
prop(fabric.Text, 'Hello world!', {
    left: 0,
    top: 0,
    fontFamily: 'Arial',
    fontWeight: 'Bold',
    fontSize: 100,
    fill: 'white',
})
```
Because `withmove` is a `Promise`, you can use the `then` method to wait for the rendering process.
```js
...}).then(() => console.log('Video successfully rendered'))
```

## Options

### **Renderer**

| Properties | Type | Description |
| - | - | - |
| **width** <br> \*_required_ | `Number` | canvas width |
| **height** <br> \*_required_ | `Number` | canvas height |
| **fps** <br> \*_required_ | `Number` | animation fps |

| Parameter | Type | Repo |
| - | - | - |
| **prop** | () => { ... } 
| **fabric** | fabric.js instance | [Repo](https://github.com/fabricjs/fabric.js) |
| **canvas** | fabric.StaticCanvas | [Repo](https://github.com/fabricjs/fabric.js) |
| **anim** |  gsap.default.timeline | [Repo](https://github.com/greensock/GSAP) |

### **Encoder**

| Properties | Type | Description |
| - | - | - |
| **frameStream** <br> \*_required_ | `Readable` |  `renderer` function return value |
| **output** <br> \*_required_ | `string`| output file path |
| **fps** <br> \*_required_ | `Object` | `{ input: number, output: number }` |
| **outputOptions** <br> | `Array` | `[ '-preset veryfast', ...]` |
| **backgroundVideo** | `Object` | [See below](#backgroundVideo) |
| **backgroundAudio** | `String` | [See below](#backgroundAudio) |

### **_backgroundVideo_**

```js
backgroundVideo: {
  videoPath: string, // background video path
  inSeconds: number, // video start time (in seconds)
  outSeconds: number, // video end time (in seconds)
}
```

### **_backgroundAudio_**
```js
withmove({
    backgroundAudio: './path_to_file.mp3',
}, { ... }, ...)
```
Adds a background audio to the output. To limit the length of the original output video to the same length as the background audio, you can set the `-shortest` options in config.outputOptions.
```js
withmove({
    outputOptions: ['-shortest']
}, { ... }, ...)
```

---
_Source: https://npm.io/package/withmove · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
