Hornet – The Decemberists

Hazards of Love from Peter Sluszka on Vimeo.

I comped most of this

Hornet – Battery

Battery from Peter Sluszka on Vimeo.

So much cleanup

After effects: undocumented menu execution.

This has been around for a while but it took some serious digging on my part today to find again, figured a repost might be in order.

After Effects has two undocumented commands that you can use to work around AE’s arcane and often frustrating limitations:


function executeMenuCommand( name )
{
command = app.findMenuCommandId( name );
app.executeCommand( command );
}

The drawback of this of course is that this executes independently of the scripting workflow. In my case I needed to duplicate source footage items in the project window and alter footage interpretation (specifically, framerate). I was relatively baffled to not find a duplicate() method for a footage item… I was able to work around this using menu execution and a somewhat roundabout UID generation system.
Notice all the calls to select and deselect layers. You would also want to store your initial selection prior to executing a function like this.

pseudocode below. I wouldn’t call it pretty, but it works.


function duplicateFootageItem( item )
{
setAllProjectSelected(false);
item.selected = true;
originalName = item.name;
genName = generateRandomUid(10);
item.name = genName;
executeMenuCommand("Duplicate");
item.name = originalName;
dupedItem = findItemByName( genName + " 2"); //so cool
dupedItem.name = originalName + "_24fps"; // or whatever
return item;
}




Original credit for execute menu command comes from Chris Hatton but I can’t find the original post now except in cached form.

Feel free to post corrections and questions below. It might take me a couple of days to approve your comment, this blog is already spamtacular.

After Effects: advanced command line rendering.

This is a very simple post but one that has changed my personal workflow immensely for the better.

In every project I work on now I have two text files. These files need to be updated with your own personal paths, obviously. In batch.txt you need change this: “/path/to/my/render.txt” and in render.txt you must obviously add your own projects instead of my fake nonprojects. If you open up render.txt in TextEdit and convert it to a plain text file ( shift-command-T ) you can simply drag in the project file from the Finder.
You can also drag in multiple projects at once this way.

batch.txt:
for FILE in `cat /path/to/my/render.txt`; do echo $FILE && /bin/tcsh -c "nice +20 '/Applications/Adobe After Effects CS4/aerender' -sound OFF -mem_usage 60 120 -project '$FILE'"; done

render.txt:
/Volumes/ourServer/myProject/aep/someShot/myAep_01.aep
/Volumes/ourServer/myProject/aep/someOtherShot/myAep_02.aep
/Volumes/ourServer/myProject/aep/someThirdShot/myAep_03.aep
/Volumes/ourServer/myProject/aep/someShotOfADifferentVariety/myAep_04.aep

This is a basically a simple bash script that uses cat and a for loop to process each aep in the list.
Please do note that this will not work if you have spaces in your paths. For help on eliminating spaces from your filesystems, please see
_

To actually execute the script, simply copy the contents of batch.txt and paste it into a terminal window. The reason for keeping these files somewhere on the server is so that you can access them easily from any machine you might be rendering on.

Now what this script will output is the following:
/bin/tcsh -c "nice +20 '/Applications/Adobe After Effects CS4/aerender' -sound OFF -mem_usage 60 120 -project '/Volumes/ourServer/myProject/aep/someShot/myAep_01.aep'"
/bin/tcsh -c "nice +20 '/Applications/Adobe After Effects CS4/aerender' -sound OFF -mem_usage 60 120 -project '/Volumes/ourServer/myProject/aep/someOtherShot/myAep_02.aep'"
/bin/tcsh -c "nice +20 '/Applications/Adobe After Effects CS4/aerender' -sound OFF -mem_usage 60 120 -project '/Volumes/ourServer/myProject/aep/someThirdShot/myAep_03.aep'"
/bin/tcsh -c "nice +20 '/Applications/Adobe After Effects CS4/aerender' -sound OFF -mem_usage 60 120 -project '/Volumes/ourServer/myProject/aep/someShotOfADifferentVariety/myAep_04.aep'"

To spell it out, this calls our aerender command four times, once with every project in the text file. After Effects will launch, render what is on the queue per the instructions, quit, and then proceed to the next line. If that ain’t fine I don’t know what is.

After Effects: basic command line rendering.

(actually this is a tutorial on quotation marks management)

This aims to explain how to do after effects rendering on the command line. This is a desirable method of working for a number of reasons which I might go into later. I hope that by articulating this I can impart something of a deeper understanding for how this stuff works. Let’s get started. In an ideal world the command is very simple. It would look like this:

aerender -project myAep.aep

here is the command color coded with matching explanation:

aerender -project myAep.aep
this part calls the aerender program this is a flag this is the value of the flag

Nice and easy. We open the rendering executable and tell it that we want it to use myAep.aep as its argument. aerender knows that when passed a -project flag to open the project and render everything on the renderqueue. aerender is not an interactive program. if you just run:

aerender

It will print out help information and quit. Most useful. We run into 2 immediate problems though with our command

problem #1: we are most likely not in the same directory as our .aep file
problem #2: we are almost definitely not in the same directory as aerender

When you open a window in Terminal.app it opens a shell. The default shell for osx is bash. There are many types of shell but damn near all of them open by default in the same place, which is Home. Shorthand for Home in the shell is

~

~ is synonymous with /Users/you/

Chances are you don’t have aerender or your project aeps in ~. So we must specify paths to both of these. This makes the command a lot uglier:

/Applications/Adobe\ After\ Effects\ CS4/aerender -project /Volumes/Active\ Projects/aep/DEC_trans_am_091409_07.aep

The observant reader will notice some backslashes. These backslashes are necessary when spaces exist in a shell command because they escape the character following it.
A synonymous way to do it would be to enclose the paths in quotes:

"/Applications/Adobe After Effects CS4/aerender" -project "Volumes/Active Projects/aep/DEC_trans_am_091409_07.aep"

There is no practical difference with these approaches. A convenient way to get paths is to drag a file from the finder into a terminal window, which will automatically print its path. The approach we choose matters, however, when we get more complicated. For many people this much is sufficient. If the command gives you an error, check your grammar, paths, and punctuation. 90% of the time people have the wrong path or a misplaced /

Note that this next line has unescaped space characters (this will not work):

/Applications/Adobe After Effects CS4/aerender -project /Volumes/Active Projects/aep/DEC_trans_am_091409_07.aep

This is what a typical human sees:


/Applications/Adobe After Effects CS4/aerender
this is a path to aerender
-project
this is the flag
/Volumes/Active Projects/aep/DEC_trans_am_091409_07.aep
this is a path to my project

and this is what a computer sees
/Applications/Adobe
THIS IS A THING
After
THIS IS A THING
Effects
THIS IS A THING
CS4/aerender
THIS IS A THING
-project
THIS IS A THING
/Volumes/Active
THIS IS A THING
Projects/aep/DEC_trans_am_091409_07.aep
THIS IS A THING

The command that Lloyd Alvarez’s bg renderer puts forth, additionally, wraps the aerender command in a different shell (I assume for backwards compatibility reasons). I suspect there’s not really any reason to do this anymore but who am I to argue with Lloyd. Let’s get fancy:

/bin/tcsh -c "nice +20 '/Applications/Adobe After Effects CS4/aerender' -sound OFF -mem_usage 60 120 -project 'myAep.aep'"

A bunch of things to note here. First and most importantly note that the whole command being passed to /bin/tcsh is wrapped in quotes. Especially note that the quotes around the after effects executable path and the project path are now enclosed in single quotes instead of double quotes. This is necessary because if we used double quotes we’d have the computer thinking this:

/bin/tcsh
THIS IS A THING
-c
THIS IS A THING
"nice +20 "
THIS IS A THING
/Applications/Adobe
THIS IS A THING
After
THIS IS A THING
Effects
THIS IS A THING
CS4/aerender
THIS IS A THING
" -sound OFF -mem_usage 60 120 -project "
THIS IS A THING
myAep.aep
THIS IS A THING
""
THIS IS A THING

Note that this:
/bin/tcsh -c "nice +20 '/Applications/Adobe After Effects CS4/aerender' -sound OFF -mem_usage 60 120 -project 'myAep.aep'"

is functionally identical to this:
/bin/tcsh -c 'nice +20 "/Applications/Adobe After Effects CS4/aerender" -sound OFF -mem_usage 60 120 -project "myAep.aep"'

See the difference? I told you this was about quotes.

There are some additional flags to note in this script: -mem_usage provides memory options, -sound is pretty self explanatory. Another favorite (or not) is -mp which turns multiprocessing on or off.
In addition, the aerender executable is itself being passed as an argument to nice which is a nifty program that allows you to set application priorities, but we won’t get into that here.

Please let me know if I have any computational or typographic errors. This is not meant to be an official resource. I am not affilated with Apple nor Adobe.

Also, if you have CS3 instead of CS4 you’ll need to change that in all of the examples.