Giter Site home page Giter Site logo

d-akara / jslib-after-effects-node Goto Github PK

View Code? Open in Web Editor NEW

This project forked from benzed/after-effects

1.0 1.0 0.0 322 KB

Define a function in Node, execute function within After Effects process and receive results in Node

License: MIT License

JavaScript 100.00%

jslib-after-effects-node's Introduction

after-effects-node


Originally forked from After Effects, but is now mostly a complete rewrite.

Currently this is experimental. Expect all updates will likely break things.

Notable Features plus Differences between original fork

  • Same Features
    • Send a JS Function from Node environment and execute within After Effects process
    • Transforms ES6 into ES3 for compatibility in After Effects JS environment
  • Differences
    • Support some additinoal ES6
    • Improved ability to send and receive JSON objects between Node and After Effects
    • Ability to turn After Effects objects into JSON
    • Error reporting back to the Node process with line # and line text of the source of error
    • Logger called by invoking log.info()
      • Logger automatically converts After Script objects into JSON that can be logged
      • Logging occurrs to a log file as well as to the Node console
    • All files generated in current working directory for easier debugging
      • All files persist after script execution for easier debugging
      • Generated JS file can be run in After Effects debugger environment as well to assist with debugging
    • Automatically adds undo group around executing script
    • Only supporting Windows ( the only environment I have to develop and test )
    • Much simplified API
      • I'm building and supporting only what I'm using at the moment, much of the original API was removed.
      • Automatically scales all clips added to layer to match the composition size

Future considerations

  • Convert library to TypeScript

Sample Usage

This script will do the following

  • Import all .mp4 files from a directory
  • Add all imported files to a composition
  • Layout all clips with overlapping 2 seconds
  • Return back to the Node process all of the video clip end times between clips
const makeAfterEffectsInterface = require('./index.js').makeAfterEffectsInterface

// These options will be passed to the after effects process and our function will receive them as a paramter to the function
const options = {
    "assetFolder": "C:\\development\\projects\\videos",
    "compositionMain": {
        "name": "render main",
        "layerOverlapSeconds": 2,
        "videoLengthLimitSeconds": 120
    },
}

const aeInterface = makeAfterEffectsInterface({afterEffectsPath: 'C:\\Program Files\\Adobe\\Adobe After Effects CC 2019'})
const result = aeInterface.executeFunctionInAfterEffects(optionsFromNode => {
    log.info('begin after effects script execution')

    const {options} = optionsFromNode
    const assetsInterface = makeAssetsInterface(app.project)
    const projectInterface = makeProjectInterface(app.project)
    const layersInterface = makeLayersInterface(assetsInterface.findByName(options.compositionMain.name))
    const importedAssets = projectInterface.importAssets(options.assetFolder, '*.mp4')
    
    const videoEndTimes = []

    log.info('creating layers')
    layersInterface.addAll(importedAssets, options.compositionMain.layerOverlapSeconds, (layer, previousLayer) => {
        log.info('  adding layer: ' + layer.name)

        if (previousLayer) {
            // make a list of the transition times to be used later
            videoEndTimes.push(previousLayer.outPoint)
        }

        if (layer.outPoint > options.compositionMain.videoLengthLimitSeconds) return true // don't add anymore beyond time limit
    })

    log.info('After Effects finished processing script')
    return videoEndTimes
}, {options});

// log list of video clip end times
console.dir(result, {depth: null})

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.