Skip to main content
Chris_VDB
Participant
April 4, 2017
Answered

Adding a second output in Extendscript for Media Encoder

  • April 4, 2017
  • 2 replies
  • 4247 views

Hi,

I am using Extendscript to automate rendering from After Effects projects.

In the Extendscript toolkit, or through BridgeTalk, I can make the following work with AME cc:

var fnt = app.getFrontend();

var ech = app.getEncoderHost();

var exp = app.getExporter();

//The comp to be rendered

var cmp = "F:\\ProjectsAE\\AEProject.aep";

//AME presets to be used (I had to copy the epr files from their original location to a simple path for this to work)

var pst = "C:\\AMEPresets\\AVC-Intra Class100 1080 50i.epr";

var pst2="C:\\AMEPresets\\PAL DV Widescreen.epr";

//Output files without extensions

var out = "F:\\ProjectsAE\\Render\\AEProject_Onair";

var out2="F:\\ProjectsAE\\Render\\AEProject_Preview";

//This adds onair preset/output

fnt.addCompToBatch(cmp,pst,out);

//This adds preview preset/output for the same comp

fnt.addCompToBatch(cmp,pst2,out2);

//This starts rendering

ech.runBatch();

//This deletes the queue

//exp.removeAllBatchItems();

The problem is that two render items are added in the batch, one for each output preset.

I'd like to add both output presets to the same render item, so both can render simultaneously instead of one after another.

Is there an extendscript method to do so?

Is there some kind of documentation for AME extendscript?

The last "extendscript is unsupported for AME" messages date back from 2 years ago. Is anything supported by now?

Even if it's preliminary or beta, I'd love to know how to use it. Especially the syntax for the other addToBatch commands.

Chris

    This topic has been closed for replies.
    Correct answer Bruce Bullis

    Bruce-

    Following up on your post here,  now that we are post-NAB, any more thoughts on Media Encoder scripting? 

    Thanks


    Yes! AME scripting is now officially supported. No documentation, of course—wouldn't want you to think we'd gone soft.

    Write me directly (day job = b b b at adobe dot com) with a description of the workflow(s) you'd like to support, and I can provide better guidance.

    2 replies

    Chris_VDB
    Chris_VDBAuthor
    Participant
    May 16, 2017

    Hi Justin,

    About the need to have only one comp in the root of your project:

    My solution is to have all working comps in subfolders, and copy only the one you need to send to AME in the root folder, using a predefined name:

    This is my extendscript (simplified)

    //Important: To work with AME, The render comp MUST be the only comp in the root folder

    //Only the first comp found will be rendered!

    //Remove any existing rendercomp in the root folder (there can be only one!)

    var oldComp = findCompInProject("AMERenderComp"); //This is not a standard function, I created my own!

    if(oldComp!=null) oldComp.remove();

    //Copy this comp, move it to the root folder and rename

    var theComp = findCompInProject("Comp_to_be_rendered");

    var dupComp = theComp.duplicate();

    if(dupComp!=null) {

         dupComp.parentFolder = app.project.rootFolder; //built-in FolderItem object for the root folder

         dupComp.name = "AMERenderComp"; //Rename

         SaveFile = new File("SaveProject.aep");

         app.project.save(SaveFile); //Save this as the file to be sent to AME

    }

    Chris

    Justin Taylor-Hyper Brew
    Community Expert
    Community Expert
    May 16, 2017

    Thanks for posting that Chris! I ended up using a similar method by consolidating all items into a subfolder with the master comp in the root. My temporary workaround for rendering one comp while maintaining the project's folder structure was to put all the consolidate methods in an undo group, save as a new .aep file specifically for the AME Render, and then undo the group and re-save to the original project file so you can continue working. I wish we could automate the "Save As Copy" in Extendscript, but for now this is the best method I could come up with. Best!

    In case anyone else is interested in my workaround:

    Consolidate as a separate file, save as export .aep, and then re-save over the original to preserve your project.

         // 1. Create Temp Consolidated File For Rendering //

              var projFile = new File(File.decode(app.project.file));

              var tempFolder = new Folder(projFile.path.toString() + "/AME_temp"); var dateStamp = new Date(); dateStamp = dateStamp.getTime();

              var tempProjFile = new File(tempFolder.toString() + "/" + app.project.file.name.toString() + aItem.name.toString() + "[" + dateStamp.toString() + "].aep");

              app.project.save(); app.project.save(tempProjFile); // Save Original File then Save Temp File

              app.beginUndoGroup("AME Export");

              app.project.reduceProject(aItem); // Reduce

              aItem.parentFolder = app.project.rootFolder; // Move active comp to Root for AME to recognize

              var allItems = app.project.items;

              var assetsBin = app.project.items.addFolder("-Assets");

              for (var i = 1; i < allItems.length; i++) {

                  if(allItems.name != assetsBin.name && allItems.name != aItem.name)

                      allItems.parentFolder = assetsBin;

              }

              app.endUndoGroup();

              app.project.save();

              app.executeCommand(16); // Executes undo function to restore original

              app.project.save(projFile);  //Save Consolidated File

    And then to Send to AME:

            // 2. Create Export Command for AME //

            var bodyText = "";     var myFile = tempProjFile.fsName;

            // Loop for each preset and add command to bodyText //

            for (var i = 0; i < myDestination.length; i++) {

              bodyText += "ameFront.addCompToBatch('" + myFile.toString() + "', '" + myPreset + "', '" + myDestination + "');";

            }

            var fileString = "var ameFront = app.getFrontend();" + bodyText;

           

            // 3. Send Command to AME for Export //

             var bt      = new BridgeTalk();

             bt.target   = 'ame';

             bt.body = fileString;

             bt.send();

    Chris_VDB
    Chris_VDBAuthor
    Participant
    May 17, 2017

    Interesting idea of using an undo group.

    I don't really trust the "reduce project" feature. Some expression errors pop up in some templates, so I don't use it.

    For "Save a Copy..." try this one: (tested OK in AE 2017)

    app.executeCommand(2166);

    It will pop up the dialog to save a project as a copy.

    fyi: It has been posted here before, but the SBLECC (Secret Black List of ExecuteCommand Codes) can be found on

    https://www.provideocoalition.com/after-effects-menu-command-ids

    Justin Taylor-Hyper Brew
    Community Expert
    Community Expert
    April 11, 2017

    Chris,

    I'm in the same situation as you, and an Adobe rep just recently confirmed that Media Encoder scripting is currently unsupported. I posted a question on this exact issue, and the word from Bruce Bullis is that there is no current function to send multiple output modules in Encoder from Premiere or After Effects.

    I've been digging around in ESTK, like I assume you have, and have found several methods such as .addItemToBatch() and .addCompToBatch(), but nothing allowing multiple output modules. I also don't see any way to specify which After Effects comp you want to export when selecting an .aep file, it currently just grabs the first comp it finds, have you found a solution to this?

    Bruce Bullis​ anything you can add to this conversation and or are you guys planning to support AME scripting in the near future?

    Thanks!

    Bruce Bullis
    Community Manager
    Community Manager
    April 11, 2017

    We cannot comment on the feature set of unannounced versions of Adobe products.

    With that in mind, I'd appreciate the community's patience in awaiting substantive reply, closer to (or soon after) NAB.

    PS: Many scripters export the active Comp to a new .aep before rendering it, and some archive that .aep with the output file...in which case, the comp-to-be-rendered is determined DETERMINATE. [shakes fist emptily at auto-correct's insensitivity to Epistemology...].

    Justin Taylor-Hyper Brew
    Community Expert
    Community Expert
    April 11, 2017

    Thats understandable. Appreciate your help!