Controlling aerender via Scripting

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
BigMacGyver
Posts: 19
Joined: May 7th, 2013, 6:43 am

September 25th, 2013, 6:07 am

Hello,

i am having a little bit of a problem in understanding how to control the aerender via scripting. The aerender is a command line or terminal app that requires arguments executed in the terminal in order to work. What is the best way to have a script pass these arguments to the terminal? Here is what i tried:

1. Creating a text file, saving it as a .command file and have the script manipulate the content of this file (adding new directories for instance), then execute. However, this fails because in order to be executable after each modification, the file must receive admin rights over and over again (it keeps asking for it no matter what i do). So this is not practical really and i would prefer to have a more direct way anyways.

2. Use apple script to first open the terminal and then passing arguments to it. But here is where i fail: I am using the system.callSystem(); thing in order to run the applescript. The following was just pieced together from various sources, including a post in this forum:

Code: Select all

system.callSystem('osascript -e \'   activate application "Terminal"\'') ; 

system.callSystem('osascript -e \'   tell application "Terminal" to open ["/Applications/Adobe\\ After\\ Effects\ CS5.5/aerender"] \'');
It's really weird. Sometimes this code works and actually manages to run the aerender. Of course without the arguments, the renderer won't work. When i add the arguments though, the whole thing fails. From that point on, nothing will work. I am not a huge expert for applescript but it feels like something i could understand quickly. But i am not sure if this is even necessary?

I don't want to bore you with too many details. What i need is really straight forward: I need a way to have a script pass command line arguments to the terminal in order to tell aerenderer what it needs to render and how. Somehow it feels like i am really close already. I might just need a small wink to the right direction.
BigMacGyver
Posts: 19
Joined: May 7th, 2013, 6:43 am

September 26th, 2013, 7:48 am

Okay, i just went over this stuff several times. I did not understand at first that i can input terminal commands via system.callSystem() directly without having to put them into an apple script.

I am now able to launch the aerenderer either by using the direct terminal command, which processes the render in the background but has the script waiting for the render process to finish:

Code: Select all

system.callSystem('time command /Applications/Adobe\\ After\\ Effects\\ CS5.5/aerender -project /Users/macname/projects/code/RenderReportTest_2.aep -v ERRORS');
or by using the apple script version, which will actually make the rendering process visible inside a terminal window but does not have the script waiting for the end of the render process:

Code: Select all

system.callSystem('osascript -e \'tell\ application\ "Terminal"\ to\ do\ script\ [\"time\ command\ /Applications/Adobe\\\\ After\\\\ Effects\\\\ CS5.5/aerender\ -project /Users/macname/projects/code/RenderReportTest_2.aep\"]\'');
both have their advantages and disadvantages.

The direct terminal command does not return you any feedback about the rendering process and on top of it all, it freezes the script and thus after effects until the render is done. However, at the end of the render, the callSystem will return a string with the render time of the item coming from the terminal command "time". I can use this for notifications of the total render time. The applescript variant does not return the time values for some weird reason. Maybe somebody knows why? The only thing it returns is a strange window information two times.

Is there a way with any of these methods to extract the information about total and item render times from the terminal? I was thinking of making it possible to submit individual comps to the renderer to extract individual comp render times. So each comp in the queue would be an individual render job for aerender. What is the best way to make this happen? I already sort of made it work for the direct command line method without the applescript, but that one has the two disadvantages noted above (you do not see the render process and the script freezes while rendering). Please let me know if you have any ideas for this.

Is there maybe a way to create some kind of progress bar for the command line method? I feel like the render process should really have some sort of visual reference instead of just happening without info while putting the script in waiting position.
drockne
Posts: 13
Joined: March 2nd, 2012, 10:10 am

March 7th, 2014, 9:47 am

I went through a similar process trying to figure this out. What I landed was creating a .command file like you did, saving it, then running a command line command to give that .command file execution permissions. Then doing a second command line command to run that file. It's a little convoluted, but it ends up running your AERender node in a command dialog box that isn't tied to your script so your script is free to move on. All totaled these steps happen super fast so you won't really notice it.

Keep in mind that if you give AE permission to write files via scripts it has admin rights and can make .command files executable without any extra user input.
Post Reply