Nexrender: Slow Render

Created on 18 Apr 2017  Â·  21Comments  Â·  Source: inlife/nexrender

Hey there,

Thanks so much for making this. Having heaps of fun using it, i have a quick question about the rendering process though. When the process gets to rendering in the command line it seems to take much longer than usual.

If i use the render queue inside afyer effects it takea about 5 seconds to render with the h264 module, although it seems to take about 30seconds in nexrender. Is this normal? Its the rendering that tales time in the commandline, moving/renaming/downloading of files is quick.

Thanks!

question

Most helpful comment

@Inlife I'm doing by this way, but I think the best way to do it is by Regular Expressions.

for (let expr of expressions) {
                // extract hex from xml tag and decode it
                let hex = expr.split('"')[1];
                let dec = new Buffer(hex, 'hex').toString('utf8');

                var newStr = dec.split("|");

                if(newStr.length>1){
                    var command = "model."+newStr[1];
                    var newValue = String( eval( command ) );
                    let enc = new Buffer( dec.replace("|"+newStr[1]+"|", newValue) ).toString('hex');
                    data = data.replace( hex, enc );
                }
            }

So, inside the After Effects file, I'm writing the expressions like |foo.bar|
And after execute the eval command, it is going to look for the prop foo.bar in the model object, and replace the variable in the expression by its value as a String.

var model = { foo:{ bar: "teste" } }

All 21 comments

Hello,

Thank you!)

although it seems to take about 30seconds in nexrender

Well, this might be related to actual aerender settings. You can try playing and changing some of them
https://github.com/Inlife/nexrender/wiki/Rendering-node#details

You can change amount of memory, and/or change to multithreaded rendering. These options are described on Adobe forums and pages, so try googling them.

And i guess they are exactly what you need :)
Cheers!

And also, if you are using it not from cli
(custom renderer code, you can set both of these parameters via js too)
this is how they are set up in the original render node js code:

    ...
    process.env.AE_MULTIFRAMES  = opts.multiframes  || '';
    process.env.AE_MEMORY       = opts.memory       || '';
    ...

@Inlife do you know a way to improve the expressions performance. Because I'm doing some tests, and when I add the expressions to get data from a external file it increase a lot the rendering time.
Without getting data from external file it is taking about 8 seconds. And when I add the expressions it takes about 25sec.

hm, well, you see, each expression is evaluated on every frame of the render process
this is the way how it works

my personal recommendation is to make as many validations before any heavy executions as possible

lets say some particular line of code will be required to run only after > 3240th frame of the video, this can be checked before doing something inside

js was always known for its slow computation speed regarding to numbers (comparing to native, compiled stuff)

also, i don't know for sure, but seems like adobe is opening file each frame for every expression
if this is the case, this is not a very good idea to write that much of the code

actually now, you've got me thinking about, maybe we somehow need to put actuall js code inside expression, not just a filepath, however this brings us to some inconveniences while in template-designing mode

I assume this is what is happening with me too since when rendered in after
effects the expressions are already loaded as the render time is almost
30seconds longer when ran through nexrender.

On Wed, 19 Apr 2017 at 09:47, Vladislav Gritsenko notifications@github.com
wrote:

hm, well, you see, each expression is evaluated on every frame of the
render process
this is the way how it works

my personal recommendation is to make as many validations before any heavy
executions as possible

lets say some particular line of code will be required to run only after >
3240th frame of the video, this can be checked before doing something inside

js was always known for its slow computation speed regarding to numbers
(comparing to native, compiled stuff)

also, i don't know for sure, but seems like adobe is opening file each
frame for every expression
if this is the case, this is not a very good idea to write that much of
the code

actually now, you've got me thinking about, maybe we somehow need to put
actuall js code inside expression, not just a filepath, however this brings
us to some inconveniences while in template-designing mode

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/Inlife/nexrender/issues/33#issuecomment-295169196,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALSnybJ2sICokL-9zKmT8hitVDpO6QRrks5rxcoygaJpZM4NArQu
.

@wst-shorty hm, i think this "loading" behavior same for both modes. I dont think that after effects acts any way different from aerender binary, which it has been using before.
Maybe they've changed it with Media Encoder, don't know about that.

However considering js nature, and the fact thats theoretically its run-time execution, they should load file each time exactly the way how it was shown.

So i think, your performance stuff is actually related to the settings, because AE for sure uses some settings from your AE preferences panel, while nexrender can't know about them. So i suggest you to try changing those settings via nexrender, and measure the results :)

@wst-shorty are cleaning the Disk and Memory cache in After Effects before rendering? Maybe AE is caching the expressions and making it faster. And it doesn't happen in aerender.

@Inlife yes, exactly! the AE execute the expression every frame. I'm trying to find a way to execute just 1 frame. But the only way I've found until now is converting the layers that are using expressions to a sub composition, and freezing the frame. But it is not practical when you have several expressions.

well, also if i understand correctly we cannot use memory (global vars) inside js expression, because its creating a "vm" for each expression and its state-less

especially, considering this quote from adobe's site:

Note: You must define each function fully within each expression in which it is used. There is no global library of functions that you can add to.

and i'm pretty sure that we cannot change values of expressions in project runtime (via project rewriting while its rendering) (_NEEDS TESTING_)
and we don't have any chance of connecting the ae scope to any our remote storage/scope in the nexrender

next paragraph is pure theoretical imagination:
seems like only way, of doing that, is somehow figuring out all the calculations in beforehand once, and just storing them inside project
(creating giant arrays of data for each frame for every expression)
yeah, it will take tonns of space, especially for projects >1 hour long :D
however we don't know about data inside AE which is calculated on runtime

Just trying to change these settings to run some test. I am having trouble adding the memory settings. Can i add the below to the start.js file? or would it go somewhere else?

    process.env.AE_MULTIFRAMES  = opts.multiframes  || '';
    process.env.AE_MEMORY       = opts.memory       || '';

try moving it to the top of the file, and setting proper values
like this:

process.env.AE_MULTIFRAMES = true;
process.env.AE_MEMORY = '50 25';

var nexrender = require('nexrender');
...

to understand what these options are doing you can look at the description of aerender binary parameters
https://helpx.adobe.com/after-effects/using/automated-rendering-network-rendering.html
(-mp and –mem_usage)

Thanks Mate. So i have got it to run normally with aerender with the different file settings this is the output given. It takes about 28 seconds to do a 13 second clip. Do you think this is due to it checking against an expression on every frame? (as mentioned above)

screen shot 2017-04-19 at 22 54 53
screen shot 2017-04-19 at 22 55 24

Another way that I'm thinking to do it, is to input the variables in the After Effects file, by the same way the nexrender change the path of the model file.
It works! But I'm having some problems to deal with the special characters.
The expressions to get the data from an external file clearly increase a lot the rendering time.

@jcmidia

Another way that I'm thinking to do it, is to input the variables in the After Effects file, by the same way the nexrender change the path of the model file.

its a great idea! It will be nice if you can show me as soon as you'll have working example. Maybe we can implement such technique inside nexrender

@kick-push yea, file operations are known for their slowness, and also js interpretation takes some time too

i remember rendering for 18-20 straight hours only 1 hour videos (well it was 60fps, but still) :D

@Inlife I'm doing by this way, but I think the best way to do it is by Regular Expressions.

for (let expr of expressions) {
                // extract hex from xml tag and decode it
                let hex = expr.split('"')[1];
                let dec = new Buffer(hex, 'hex').toString('utf8');

                var newStr = dec.split("|");

                if(newStr.length>1){
                    var command = "model."+newStr[1];
                    var newValue = String( eval( command ) );
                    let enc = new Buffer( dec.replace("|"+newStr[1]+"|", newValue) ).toString('hex');
                    data = data.replace( hex, enc );
                }
            }

So, inside the After Effects file, I'm writing the expressions like |foo.bar|
And after execute the eval command, it is going to look for the prop foo.bar in the model object, and replace the variable in the expression by its value as a String.

var model = { foo:{ bar: "teste" } }

@jcmidia Hey Julio, I was wondering if I could grab a copy of your files. I am trying speed up my process but haven't been able to, would love to check out a working copy of yours if possible!

Thanks

@jcmidia Do you have a base project with this working? I am trying to achieve the same as above.

@kick-push @wst-shorty sorry, I was traveling and didn't see the messages. Actually I'm not using the nexrender and the project is for a company that doesn't allow me to share the code.
But the code above can be replaced in the file in: node_modules/nexrender/renderer/tasks/patch.js
Maybe you can use the project variable to send the model, so you can replace the code var command = "model."+newStr[1]; for something like var command = "project.model."+newStr[1];

Hi all
I did some tests with the new features on After Effects 2018. Now we can use a json file as a asset, and it seems that it doesn't make the render slow like the evalFile expression does. I'm not using Nexrender on my Data Driven projects, but I guess that you guys can use a json as a placeholder with nexrender, and it should work fine.
https://helpx.adobe.com/after-effects/using/data-driven-animations.html

new approach of using after effects scripting engine has been added in latest pre-release version, closing the issue

Thanks Mate. So i have got it to run normally with aerender with the different file settings this is the output given. It takes about 28 seconds to do a 13 second clip. Do you think this is due to it checking against an expression on every frame? (as mentioned above)

screen shot 2017-04-19 at 22 54 53

screen shot 2017-04-19 at 22 55 24

Hi, Can u send me the sample project and NodeJS code that u used for rendering in such a quick time. It would be a big help for me. Thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leq382121 picture leq382121  Â·  6Comments

FRANK-AND-FREE picture FRANK-AND-FREE  Â·  4Comments

oskobri picture oskobri  Â·  3Comments

bluematter picture bluematter  Â·  5Comments

byumark picture byumark  Â·  3Comments