Coder Social home page Coder Social logo

etro-node's Introduction

Etro for Node

Sometimes it's useful to use Etro in Node. This package is a wrapper of Etro that serves that purpose.

Usage

etroNode(() => {
  // You can access inputs as html elements and pass them to Etro as usual.
  const image = document.getElementById('input1') // <img> element
  ...
  movie.exportRaw()
    .then(window.done)
// Tell Etro Node what inputs to load with { id: path }
}, { input1: 'path/to/image.png' }, 'output.mp4')

Documentation

etroNode(etroFunction, inputSources, resultCallbackOrPath[, page])

  • etroFunction (string) - Function to run in the puppeteer page. etro and done are exposed as globals (accessed as properties of window)
    • window.done(exportedBytes) - Process the exported movie (resolved value of Movie#exportRaw), by either writing to resultCallbackOrPath if it's a string or executing it if it's a function
  • inputSources (Object<string, <string|Object>>) - the input assets, mapped from id to path or raw data. If the input is provided as raw data, it should be an object with the following properties:
    • type (string) - the MIME type of the input source
    • data (Buffer)
  • resultCallbackOrPath (function|string) - Determines what to do when window.done is alled in etroFunction. If it's a string, it is treated as a path and the movie is written to it. If it's a function, it is called with one argument exportedBytes.
  • page (Page) - the puppeteer Page to use. Defaults to a page created by a new browser.

Runs etroFunction in a puppeteer page. Each input source is converted to an html element (<img>, <audio> or <video>). The output is either written to the path or the callback is executed, depending on the type of resultCallbackOrPath.

Changelog

0.1.0 - 2020-09-30

Added:

  • etroNode - the etro wrapper
  • Movie#recordRaw - a convenience method for recording in the etro wrapper

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

GPLv3

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.