npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dramadirector

v1.0.1

Published

Nodejs video/lottie/audio/text/image schema composition service based on ffmpeg

Downloads

6

Readme

DramaDirector

Nodejs video/lottie/audio/text/image schema composition service based on FFmpeg

🐾 Example

  • Start the demo
npm i
npm run build
npm run demo
  • 【optional】By excuting npm run demo 1 , generate the video by stream mode.
  • Then you can see demo.mp4 in example folder.

💫 How to generate a schema for your own composition?

You can refer to the schema.js in the demo folde. The example in this file includes the basic attributes required for the basic elements in video composition.

Basically, the schema comprises basic info(name,width,height,duration) and layers info. And each layer comprises several or single items.

💾 Layer

  • index: id of this layer
  • type: normal/audio/lottie/text
  • items:items in this layer

💿 VideoItem

  • id : id of this layer
  • type : video
  • url : local path or network link of the resource
  • config : the basic info of the item

| attr | type | usage | | ---- | ------------- | -------------------------------------------------- | | st | number/srting | the start time of the item in the whole production | | et | number/srting | the end time of the item in the whole production | | seek | number/srting | from which second does the item start playing | | x | number/srting | position x | | y | number/srting | position y |

  • effects : the effects on the items(filters like scale,blur, follow the rule of fluent-ffmpeg)

    | attr | type | usage | | ------- | ------------- | ---------------- | | nm | string | name of filter | | options | string/object | option of filter |

🎇 ImageItem

  • id : id of this layer
  • type : image
  • url : local path or network link of the resource
  • config: the basic info of the item
  • effects : the effects on the items(filters like scale,blur, follow the rule of fluent-ffmpeg)

🎊 LottieItem

  • id : id of this layer
  • type : lottie
  • lottie : object of lottieJson
  • config: the basic info of the item

| attr | type | usage | | ---- | ------------- | -------------------------------------------------- | | st | number/srting | the start time of the item in the whole production | | et | number/srting | the end time of the item in the whole production | | seek | number/srting | from which second does the item start playing | | x | number/srting | position x | | y | number/srting | position y | | fps | number/srting | frame rate | | w | number/srting | width, currently needed | | h | number/srting | height, currently needed |

  • effects : 【TODO】the effects on the items(filters like crop,blur, follow the rule of fluent-ffmpeg)

🎼 TextItem

  • id : id of this layer
  • type : text
  • url : local path or network link of the resource
  • config: the basic info of the item

| attr | type | usage | | ----------- | ------------- | -------------------------------------------------- | | st | number/srting | the start time of the item in the whole production | | et | number/srting | the end time of the item in the whole production | | text | string | text | | fontcolor | string | color of text | | fontsize | number/string | size of font | | bordercolor | string | color of inner border | | borderw | number/string | width of inner border | | obc | string | color of outer border | | obw | number/string | color of outer border | | ttfPath | string | local path of .ttf file |

  • effects : the effects on the items(filters like scale, follow the rule of fluent-ffmpeg)

🎼 AudioItem

  • id : id of this layer
  • type : lottie
  • url : local path or network link of the resource
  • config: the basic info of the item

| attr | type | usage | | ---- | ------------- | -------------------------------------------------- | | st | number/srting | the start time of the item in the whole production | | et | number/srting | the end time of the item in the whole production | | seek | number/srting | from which second does the item start playing |

  • effects : the effects on the items(filters like volume, follow the rule of fluent-ffmpeg)

By using ffmpeg-utils in effects, you can even achieve the effect of keyframe animation.

Consume the schema

const DramaCore = require('../dist').default
// The schema described how the product is organized
const darmaSchema = require('./schema')
const path = require('path')
const fs = require('fs');
const [, , useStream] = process.argv;
async function run() {
    const saveFilePath=path.join(__dirname, 'demo.mp4');
    const director = new DramaCore(darmaSchema)
    console.time('task')
    if(useStream){
        const stream = director.getStream();
        const outputStream = fs.createWriteStream(saveFilePath);
        stream.pipe(outputStream);
        outputStream.on('finish', () => {
            console.timeEnd('task')
        })
    }else{
        director.save(saveFilePath).then(() => {
            console.timeEnd('task')
        }).catch(err => {
            console.log(err)
        });
    }
}
run()