Giter Club home page Giter Club logo

ae-to-json's Introduction

ae-to-json

experimental

The purpose of this module is to create After Effects JSX/JS Script cript to:

  • Export After Effects files as JSON like Objects
  • Standardize After Effects to JSON Exporters
  • Create a platform on which renderers can be built on top of
  • Have proper unit tests to catch breaking changes in After Effects

Documentation on Adobe's After Effects scripting guide can be found here:

Usage

NPM

There are a few ways that you can consume this module. They are documented below:

Usage with the after-effects module

The after-effects allows you to run "functions" in After effects. Pass it one function it will return you the value in Node. No need to use the After Effects Scripting tools. To use with after-effects:

Install after-effects:

$ npm i ae-to-json after-effects --save

In Javascript:

var aeToJSON = require('ae-to-json/after-effects');
var ae = require('after-effects');

ae.execute(aeToJSON)
.then(function(json) {
  // do something with the json outout
})
.catch(function(e) {
  throw e;
});

Usage in After Effects' Scripting tools

Copy the contents of dist/index.js. The dist build will bring in es-5 shims and a JSON shim.

In After Effects go to:

  • File
  • Scripts
  • Open Script Editor
  • Paste contents into Script Editor

You should now be able to do something like:

JSON.stringify(aeToJSON(), null, '  ');

Build and use in your own JSX Scripts

Since After Effects currently uses a Ecma Script 3 engine you will need to shim in Ecma Script 5. Also you should shim in JSON also.

Install:

$ npm i ae-to-json es5-shim JSON2 --save

Javascript:

// shim in es5 functionality
require('es5-shim');

// you might want to make JSON be a global
JSON = require('JSON2');

var aeToJSON = require('ae-to-json');

// do something with the aeToJSON function

After this you'll most likely want to browserify the Javascript file defined above.

$ browserify index.js -o bundle.js

High Level Exported Format

Here's an example on an high level what will be exported from After Effects. For a more detailed example of an export check out: https://raw.githubusercontent.com/Jam3/ae-to-json/master/example/example.json

These files can be very large since we attempt to export everything but at least this small bit of documentation will help you get started traversing the exports:

{ 
  // meta data for the project
  project: {

    // items which are used in the Project panel
    // this includes: 
    //  Compositions, 
    //  Footage (images, videos, solids, etc.),
    //  Solids,
    //  etc.
    items: [
      // Composition Type
      {
        typeName: 'Composition',
        // these are the Compositions layers
        layers: [
          {
            // this includes all properties for this layer
            // properties are things like:
            //  Transform, (position, scale, rotation, anchor, etc.)
            //  Material Options,
            //  Effects,
            //  etc.
            properties: {

              // this is what the transform property would look like
              Transform: {

                // Transform's have their own properties
                // This is what X Position on a high level would look like
                "X Position": {

                  // if a property is animatable it will contain keyframes
                  // keyframes will be a two dimension array where each element
                  // on the second dimension is a key frame
                  "keyframes": [
                    // each key frame has a time (in seconds) which is at [0]
                    // a value which is at [1] (values can be scalar values 
                    // or arrays represented by arrays)
                    // 
                    // And an optional ease value. Generally you'd need more
                    // than one keyframe to have ease values.
                    // 
                    // It should be noted if no keyframes were added in After 
                    // Effects for ease of use one keyframe will be output with
                    // the value at time 0
                    [ time, value, ease ]
                  ]
                }
              }
            }
          }
        ]
      },
      {
        typeName: 'Footage'
      },
      {
        typeName: 'Folder',
        items: [
          // this items folder would contain
          // Compositions, Footage, Solids, etc.
        ]
      }
    ]
  }
}

Export Example

You can view an export example at (be forewarned these files are huge):

https://raw.githubusercontent.com/Jam3/ae-to-json/master/example/example.json

Testing

To run tests there are two scenarios. Run a test just once or watch the src/and test/ folders and run tests. Below are the commands to run tests:

To run test once:

$ npm test

To watch and run (better for development):

$ npm start

When run unit tests are run on the JSON out along with a testOutput.json file is exported to the root director of this repo.

License

MIT, see LICENSE.md for details.

ae-to-json's People

Contributors

mikkoh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ae-to-json's Issues

Script execution error inside of After Effects: self is undefined

I am running the example from the Readme:

var aeToJSON = require('ae-to-json/after-effects');
var ae = require('after-effects');

ae.default.execute(aeToJSON)
.then(function(json) {
  // do something with the json outout
})
.catch(function(e) {
  throw e;
});

And this is the output:

(node:36935) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): AfterEffectsScriptError: Script execution error inside of After Effects: self is undefined
(node:36935) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Any ideas on this?

about adobe illustrator

Hi master:
I want to generate a text.ai from the server side. i just thought of Adobe illustrator, but i do not know if there is a package like after-effects can run illustrtor on server side.Thanks a lot!

Write unit tests

Need to improve unit tests to check exports better.

Currently it does check getting json, comp format, and layers. But there is so much more to test... 😢

Separate index.js

index.js currently has many functions baked into the scope of the main function.

This should be broken to separate modules and a build script should be written to browserify + transpile code.

See issue #3

Publish to npm

This issue can be finished once these issues have been finished (in no particular order):

  • #2 Document format details
  • #5 Remove get which comes from after-effects module
  • #6 Add shims/handling for shims
  • #8 Add docs for consuming NPM module

Crash of aeToJson, getProperties, AfterEffect CC 2017 14.2.1.34

Hi,

I have a problem with a after-effect project of 10s. When I launch a dump to Json it says the error message that I have to enable Network etc... in After Effect.

I copied the sources and modified them in order to investigate and figured out that if I comment the following line: https://github.com/Jam3/ae-to-json/blob/master/src/getProperties.js#L27 it works, (but without the subdata, normal).

I didn't find a solution yet, have you tips to avoid getting this error ? or a potential fix ?
In a VM it works perfectly, on my desktop station it doesn't (it has more RAM ... not logical).

Thanks

Any way to import?

This looks fascinating. Is there any way to go the other way, create or render a project from the JSON output?

Remove after-effects get

get is a jquery like function brought in by the after-effects module.

It would be nice to remove this dependency to ensure this script can run outside of after-effects

testProject.aep unreadable

Opening testProject.aep with AE CC v13.5.1 on a windows7 machine and getting a "unable to import file" error. "Bad format or not readable"

CC is up-to-date

Add Boiler Plate

JSX does't support all modern features of Javascript.

Therefore you have to shim in many features such as functional programming methods, etc.

It would be nice to add the bare minimum to shim in features needed and remove dependency on build script to after-effects module.

Unexpected token error

I've installed ae-to-json and the other requirements and don't get any errors when I run node someFile.js with this inside it:

var aeToJSON = require('ae-to-json/after-effects');
var ae = require('after-effects');

However, if I add ae.execute(aeToJSON) afterwards, taken from the instructions, then I get this:

SyntaxError: unknown: Unexpected token (1:9)
�[0m> 1 | �[36mfunction�[39m �[94m�[1m(�[22m�[39m�[94m�[1m)�[22m�[39m �[32m{�[39m
    |          ^
  2 | �[36mvar�[39m window �[1m=�[22m �[32m{�[39m�[32m}�[39m�[1m;�[22m
  3 | �[94m�[1m(�[22m�[39m�[36mfunction�[39m�[94m�[1m(�[22m�[39mf�[94m�[1m)�[22m�[39m�[32m{�[39m�[36mif�[39m�[94m�[1m(�[22m�[39m�[36mtypeof�[39m exports�[1m===�[22m�[31m"object"�[39m�[1m&&�[22m�[36mtypeof�[39m module�[1m!==�[22m�[31m"undefined"�[39m�[94m�[1m)�[22m�[39m�[32m{�[39mmodule�[1m.�[22mexports�[1m=�[22mf�[94m�[1m(�[22m�[39m�[94m�[1m)�[22m�[39m�[32m}�[39m�[36melse�[39m �[36mif�[39m�[94m�[1m(�[22m�[39m�[36mtypeof�[39m define�[1m===�[22m�[31m"function"�[39m�[1m&&�[22mdefine�[1m.�[22mamd�[94m�[1m)�[22m�[39m�[32m{�[39mdefine�[94m�[1m(�[22m�[39m�[33m[�[39m�[33m]�[39m�[1m,�[22mf�[94m�[1m)�[22m�[39m�[32m}�[39m�[36melse�[39m�[32m{�[39m�[36mvar�[39m g�[1m;�[22m�[36mif�[39m�[94m�[1m(�[22m�[39m�[36mtypeof�[39m window�[1m!==�[22m�[31m"undefined"�[39m�[94m�[1m)�[22m�[39m�[32m{�[39mg�[1m=�[22mwindow�[32m}�[39m�[36melse�[39m �[36mif�[39m�[94m�[1m(�[22m�[39m�[36mtypeof�[39m global�[1m!==�[22m�[31m"undefined"�[39m�[94m�[1m)�[22m�[39m�[32m{�[39mg�[1m=�[22mglobal�[32m}�[39m�[36melse�[39m �[36mif�[39m�[94m�[1m(�[22m�[39m�[36mtypeof�[39m self�[1m!==�[22m�[31m"undefined"�[39m�[94m�[1m)�[22m�[39m�[32m{�[39mg�[1m=�[22mself�[32m}�[39m�[36melse�[39m�[32m{�[39mg�[1m=�[22m�[36mthis�[39m�[32m}�[39mg�[1m.�[22maeToJSON �[1m=�[22m f�[94m�[1m(�[22m�[39m�[94m�[1m)�[22m�[39m�[32m}�[39m�[32m}�[39m�[94m�[1m)�[22m�[39m�[94m�[1m(�[22m�[39m�[36mfunction�[39m�[94m�[1m(�[22m�[39m�[94m�[1m)�[22m�[39m�[32m{�[39m�[36mvar�[39m define�[1m,�[22mmodule�[1m,�[22mexports�[1m;�[22m�[36mreturn�[39m �[94m�[1m(�[22m�[39m�[36mfunction�[39m e�[94m�[1m(�[22m�[39mt�[1m,�[22mn�[1m,�[22mr�[94m�[1m)�[22m�[39m�[32m{�[39m�[36mfunction�[39m s�[94m�[1m(�[22m�[39mo�[1m,�[22mu�[94m�[1m)�[22m�[39m�[32m{�[39m�[36mif�[39m�[94m�[1m(�[22m�[39m�[1m!�[22mn�[33m[�[39mo�[33m]�[39m�[94m�[1m)�[22m�[39m�[32m{�[39m�[36mif�[39m�[94m�[1m(�[22m�[39m�[1m!�[22mt�[33m[�[39mo�[33m]�[39m�[94m�[1m)�[22m�[39m�[32m{�[39m�[36mvar�[39m a�[1m=�[22m�[36mtypeof�[39m require�[1m==�[22m�[31m"function"�[39m�[1m&&�[22mrequire�[1m;�[22m�[36mif�[39m�[94m�[1m(�[22m�[39m�[1m!�[22mu�[1m&&�[22ma�[94m�[1m)�[22m�[39m�[36mreturn�[39m a�[94m�[1m(�[22m�[39mo�[1m,�[22m�[1m!�[22m�[35m0�[39m�[94m�[1m)�[22m�[39m�[1m;�[22m�[36mif�[39m�[94m�[1m(�[22m�[39mi�[94m�[1m)�[22m�[39m�[36mreturn�[39m i�[94m�[1m(�[22m�[39mo�[1m,�[22m�[1m!�[22m�[35m0�[39m�[94m�[1m)�[22m�[39m�[1m;�[22m�[36mvar�[39m f�[1m=�[22m�[36mnew�[39m Error�[94m�[1m(�[22m�[39m�[31m"Cannot find module '"�[39m�[1m+�[22mo�[1m+�[22m�[31m"'"�[39m�[94m�[1m)�[22m�[39m�[1m;�[22m�[36mthrow�[39m f�[1m.�[22mcode�[1m=�[22m�[31m"MODULE_NOT_FOUND"�[39m�[1m,�[22mf�[32m}�[39m�[36mvar�[39m l�[1m=�[22mn�[33m[�[39mo�[33m]�[39m�[1m=�[22m�[32m{�[39mexports�[1m:�[22m�[32m{�[39m�[32m}�[39m�[32m}�[39m�[1m;�[22mt�[33m[�[39mo�[33m]�[39m�[33m[�[39m�[35m0�[39m�[33m]�[39m�[1m.�[22mcall�[94m�[1m(�[22m�[39ml�[1m.�[22mexports�[1m,�[22m�[36mfunction�[39m�[94m�[1m(�[22m�[39me�[94m�[1m)�[22m�[39m�[32m{�[39m�[36mvar�[39m n�[1m=�[22mt�[33m[�[39mo�[33m]�[39m�[33m[�[39m�[35m1�[39m�[33m]�[39m�[33m[�[39me�[33m]�[39m�[1m;�[22m�[36mreturn�[39m s�[94m�[1m(�[22m�[39mn�[1m?�[22mn�[1m:�[22me�[94m�[1m)�[22m�[39m�[32m}�[39m�[1m,�[22ml�[1m,�[22ml�[1m.�[22mexports�[1m,�[22me�[1m,�[22mt�[1m,�[22mn�[1m,�[22mr�[94m�[1m)�[22m�[39m�[32m}�[39m�[36mreturn�[39m n�[33m[�[39mo�[33m]�[39m�[1m.�[22mexports�[32m}�[39m�[36mvar�[39m i�[1m=�[22m�[36mtypeof�[39m require�[1m==�[22m�[31m"function"�[39m�[1m&&�[22mrequire�[1m;�[22m�[36mfor�[39m�[94m�[1m(�[22m�[39m�[36mvar�[39m o�[1m=�[22m�[35m0�[39m�[1m;�[22mo�[1m<�[22mr�[1m.�[22mlength�[1m;�[22mo�[1m++�[22m�[94m�[1m)�[22m�[39ms�[94m�[1m(�[22m�[39mr�[33m[�[39mo�[33m]�[39m�[94m�[1m)�[22m�[39m�[1m;�[22m�[36mreturn�[39m s�[32m}�[39m�[94m�[1m)�[22m�[39m�[94m�[1m(�[22m�[39m�[32m{�[39m�[35m1�[39m�[1m:�[22m�[33m[�[39m�[36mfunction�[39m�[94m�[1m(�[22m�[39mrequire�[1m,�[22mmodule�[1m,�[22mexports�[94m�[1m)�[22m�[39m�[32m{�[39m
  4 | �[31m'use strict'�[39m�[1m;�[22m�[0m
    at Parser.pp.raise (C:\Users\ste\Documents\WAR\node_modules\after-effects\node_modules\babel-core\node_modules\babylon\lib\parser\location.js:22:13)
    at Parser.pp.unexpected (C:\Users\ste\Documents\WAR\node_modules\after-effects\node_modules\babel-core\node_modules\babylon\lib\parser\util.js:89:8)
    at Parser.pp.parseFunction (C:\Users\ste\Documents\WAR\node_modules\after-effects\node_modules\babel-core\node_modules\babylon\lib\parser\statement.js:639:10)
    at Parser.pp.parseFunctionStatement (C:\Users\ste\Documents\WAR\node_modules\after-effects\node_modules\babel-core\node_modules\babylon\lib\parser\statement.js:308:15)
    at Parser.pp.parseStatement (C:\Users\ste\Documents\WAR\node_modules\after-effects\node_modules\babel-core\node_modules\babylon\lib\parser\statement.js:97:19)
    at Parser.pp.parseBlockBody (C:\Users\ste\Documents\WAR\node_modules\after-effects\node_modules\babel-core\node_modules\babylon\lib\parser\statement.js:529:21)
    at Parser.pp.parseTopLevel (C:\Users\ste\Documents\WAR\node_modules\after-effects\node_modules\babel-core\node_modules\babylon\lib\parser\statement.js:36:8)
    at Parser.parse (C:\Users\ste\Documents\WAR\node_modules\after-effects\node_modules\babel-core\node_modules\babylon\lib\parser\index.js:129:19)
    at parse (C:\Users\ste\Documents\WAR\node_modules\after-effects\node_modules\babel-core\node_modules\babylon\lib\index.js:47:47)
    at File.parse (C:\Users\ste\Documents\WAR\node_modules\after-effects\node_modules\babel-core\lib\transformation\file\index.js:517:34)

It seems that the AE project is not being converted to JS properly and thus interprets it as this mess of symbols.

How can I fix this issue?

File read

Hey,

Are you planning on adding standalone aep/aepx file to json & json -> aep/aepx file tools ?
And possibly a tool for creating aep/aepx projects using json from scratch.

Hi master:

when i use this I get this error in cmd:

[email protected] test F:\ThunderDown\ae-to-json-master\ae-to-json-master
npm run open-ae; npm run test-build-run; npm run clean-root;

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\
node_modules\npm\bin\npm-cli.js" "run" "open-ae;" "npm" "run" "test-build-run
;" "npm" "run" "clean-root;"
npm ERR! node v6.2.0
npm ERR! npm v3.8.9

npm ERR! missing script: open-ae;
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! https://github.com/npm/npm/issues

npm ERR! Please include the following file with any support request:
npm ERR! F:\ThunderDown\ae-to-json-master\ae-to-json-master\npm-debug.log
npm ERR! Test failed. See above for more details.
Can you help me ?

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.