Prepare an After Effects project for Automate-IT

Modified on Wed, 2 Dec, 2020 at 1:54 PM

Recommended skills

- Very good knowledge of Adobe After Effects

- Adobe Extendscript (After Effects Scripting - Javascript ) 

- JSON


What's you need

To prepare an After Effects project you will need on your workstation :

- Adobe After Effects (up from CC2017)

- Microsoft Visual Studio Code

- ExtendScript Debugger Extension for Visual Studio Code


Useful links

After Effects Scripting Guide

The Javascript Tools Guide

After Effects Expression Reference


Configuration

To define a new template in Automate-IT you need to go in the Configuration menu and select Panels


Click on Register panel button


You need to edit all fields


Name : This is the name of the template in Automate-IT (this name will be displayed in all Automate-IT UI)

Type : You can create source data with Automate-IT forms or use legacy custom html form.

Form : Select the form you want to use to generate data

Render project name : The name of the After Effect template project file - you don't need enter file extension (.aep)

Render script name : The name of the Extendscript file name that will update your template project - you don't need enter file extension (.jsx)

Workflow designer : The delivery workflow that will be triggered after the After Effect render is done.

Activated : A checkbox to activate the template for users


Generation Sequence

What happens when a user click on generate button (or preview button) ?

  1. Automate-IT will create temp folder (with the request ID) in the rendering machine.
  2. Automate-IT will copy of the template After Effects project in this temp folder
  3. Automate-IT will open the copy of the template project with After Effects
  4. The data from the form are loaded in the Extendscipt engine (the After Effects Scripting engine)
  5. The Extendscript file is executed, the copy of the After Effects project is updated with the Extendscript file.
  6. The updated After Effects project is saved
  7. Automate-IT will send to Adobe Media Encoder all items in the After Effects render queue. Output file name will be conserved.
  8. Automate-It will trigger render in AME. Output files ares written in the local temp folder. 
  9. Once the render is done, the delivery workflow is executed to copy render file to a shared storage for example
  10. The temps folder are deleted



Working folders and template path

The working folders are defined in the configuration file in each rendering machine.

Edit this file : 

C:\Program Files\Automate-it\ait_agent-2.0\ait_agent\conf\agent.ini


The TMP_DIR section will define the local temp folders.

[paths]
LOGS_DIR = C:\Automate-IT\logs
TMP_DIR = T:\factoryTmp


The AE_TEMPLATE_PATH section will define where Automate-IT will find template project and Extendscript.


[ae_agent]
SERVER_ADDRESS = https://xxxxxxxx
SERVER_USER = xxxxx
SERVER_PASSWORD = xxxxxxxxx
NODE_NAME = render1
NODE_TYPE = LOCAL
NODE_FILTER = ANY
PYTHON_PATH = C:\Python_virtual_Env\vait\Scripts\python.exe
SCRIPT_PATH = C:\Program Files\Automate-IT\ait_agent-2.0\ait_agent
AE_TEMPLATE_PATH = \\\\10.0.4.242\Sources\templates



How to manipulate Automate-IT data in my Extendscript ?


Automate-it will generate a JSON object inside the After Effect scripting engine with this path :

JobToDo.response.content 


Example with a form with a string field with "my_text" as key.


To access this field the your Extendscript :

 

JobToDo.response.content.my_text


You can visualise the data structure of your form by double clicking the the tab in the form editor in the "current tab values.


So to update a text layer in your After Effects project :

my_composition_item.layer("my_layer_name").text.sourceText.setValue(JobToDo.response.content.my_text)



Example with a form with a Media selector.


The data generated by the form is more complex :

{
  "my_text": "Hello",
  "media_selector": {
    "connector": "Directory_Connector",
    "connector_type": "directory",
    "connector_data": {
      "connector_key": "Clean",
      "co_directory": "/mnt/Sources/clean/",
      "mode": "online"
    },
    "id": "",
    "files": [
      {
        "file_profile": "N/A",
        "file_format": "MXF (Material eXchange Format)",
        "file_duration": "0:00:46",
        "file_name": "BIG_BUCK_BUNNY_PROMO_CLEAN.mxf",
        "file_frame_rate": 25,
        "uri": "file:///mnt/Sources/clean/BIG_BUCK_BUNNY_PROMO_CLEAN.mxf",
        "file_bytes": "298931308",
        "is_video_file": true,
        "last_modification": 1459098071,
        "file_size": "298.9 MB",
        "position": 5,
        "file_seconds": "46.200000",
        "mapped_path": "\\\\10.0.4.242\\Sources\\clean\\BIG_BUCK_BUNNY_PROMO_CLEAN.mxf"
      }
    ],
    "tag": "ui-id-21_root_media_selector",
    "thumbnail": "/automateit/directory/get_file_thumb?connector_key=Clean&file_path=QklHX0JVQ0tfQlVOTllfUFJPTU9fQ0xFQU4ubXhm&co_directory=L21udC9Tb3VyY2VzL2NsZWFuLw%3D%3D&t=1606903284",
    "order": 3,
    "file_path": "/mnt/Sources/clean/BIG_BUCK_BUNNY_PROMO_CLEAN.mxf",
    "file_url": "/automateit/directory/get_file?connector_key=Clean&file_path=QklHX0JVQ0tfQlVOTllfUFJPTU9fQ0xFQU4ubXhm&co_directory=L21udC9Tb3VyY2VzL2NsZWFuLw%3D%3D&t=1606903284",
    "__media_tag__": "root_media_selector",
    "__version__": ""
  }
}


Lots of informations are available for the selected media but the most useful is the source file path.

To access the file path the your Extendscript :

JobToDo.response.content.media_selector.files[0].mapped_path


 So to import the selected media in your After Effects project :

var mediaFile = File(JobToDo.response.content.PATH_VIDEO);
if(mediaFile.exists)
{
     var media_clip = app.project.importFile(new ImportOptions(mediaFile));
     // then do what you have to do with media_clip
}


Development environment

To prepare a project it could be difficult to use a complete Automate-IT system, especially if the system is in production.

It's possible to simulate Automate-IT and manually execute Extendscript code from Visual Studio Code.

- Open your project with After Effects

- Open your Extendscript with Visual Studio Code

- Add the data generated by Automate-it at the top of your script (inside JobToDo.response.content )

var JobToDo = {
  response : {
        content : {
            "my_text": "Hello",
            "media_selector": {
                "files": [
                        {
                            "mapped_path": "\\\\10.0.4.242\\Sources\\clean\\BIG_BUCK_BUNNY_PROMO_CLEAN.mxf"
                        }
                    ]
                }
        }
    }
}


// main script
alert(JobToDo.response.content.my_text);


- Select After Effects as target app inside Visual Studio Code


- Go in the debug tab and click "Run ans debug"


...and your code is executed in After Effects 


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article