[Question][Answered] Provide AE expression example
kolyadin opened this issue · 7 comments
Can you provide an example how to simple rename text in some compositon via nexrender?
Well, it's quite simple. Result is achieved by using AE Expressions.
Firstly, you need to create a script (data source) which will be included at render process. This script must be attached as asset, and will downloaded along with rest of your project asset files.
In project it might look something like that:
Hope that helps. :)
Thank you!
You know, i am practicing in AE scripting (adobe extend tool script) and i see that some functional which is possible via scripts does not work via expressions.
Imagine situation, when we want to create personal video with scene for male or for female.
Each male/female scene is a separate layer.
So, i need an expression where i will find certain layer and remove it.
But when i remove a layer via expression i've got an error "remove method not find" or something like that.
Can you explain how to remove/add layers via nexrender and expressions or how you can handle such task?
Also very interested in nexrender+expressions restrictions.
Thanks again.
According to Adobe's limitations Expressions can be used to control very particular amount of object properties. So if you want to make complex controls of your scenes/layers/etc. you should use only AE Scripting.
However, AE Scripting requires you to open After Effects application to operate. It simply runs inside AE Application environment.
Unlike AE scripting, Expression scripting allows you to describe simple object property behaviors beforehand, and they will be executed at render runtime, without opening AE Instance.
Each male/female scene is a separate layer.
For your task, i'd used different compositions, one for male, other for female.
When you are describing a project, you can set a composition which will be rendered this time.
You can put all needed images (might be a person photo) as asset, which will be renamed to a particular name (photo.jpg). This way you can achieve dynamic image changing for each rendered video (i call this tehnique asset substitution). And you can give all needed information such as person name, age, etc in, for example, darthvader.js
script asset file, which will can be used as i've described in previous post.
The darthvader.js
file might look like this:
var person = {
name: "Darth Vader",
occupation: "Manager at DeathStar Co."
age: 45
};
And using it inside your male
composition at text filed "name":
$.evalFile("/Users/myuser/Projects/myrpoject/data.js"); person.name
Note: it's important to understand and remember about renaming of assets. In this case
darthvader.js > data.js
And project file might look like this:
{
template: 'template.aepx',
composition: 'male',
settings: {
outputModule: 'h264',
outputExt: 'mp4',
startFrame: 0,
endFrame: 542
},
assets: [
{
type: 'project',
src: 'http://localhost:3000/projects/HUMANS.aepx',
name: 'template.aepx'
}, {
type: 'image',
src: 'http://localhost:3000/images/DARTH_VADER_FACE_PROFILE.jpg',
name: 'face.jpg'
}, {
type: 'image',
src: 'http://localhost:3000/images/DARTH_VADER_DEATHSTAR_BACKGROUND.jpg',
name: 'background.jpg',
filters: [{
name: 'cover',
params: [1920, 1080]
}],
}, {
type: 'audio',
src: 'http://localhost:3000/music/IMPERIAL_MARCH.mp3',
name: 'track.mp3'
}, {
type: 'script',
src: 'http://localhost:3000/projects/darhvader.js',
name: 'data.js'
}
]
}
@inlife I'm trying to use $.evalFile("data.js")
but it doesn't accept it as a path.
It only appears to work when I define a full path i.e. C:\Project\data.js
.
I think I need to call the data.js file from the working (temp) directory in order to use the downloaded data.js file in the render node. How do I achieve this, or am I overlooking something?
just define the full path to the file on your disk, then specify it as an assest for download. Nexrender has a module to rename the paths to the temp assets directory. For this you need to provide the aepx (xml file) as input for the project so it can rewrite the directories.
hey @iadj
the problem is that adobe after effects accepts only absolute paths !
so, to solve this problem there is a so called "patching" process
it will try to find all absolute paths in expressions and replace them to paths pointing to the file in the temp directory
works only for aepx templates (xml saved)
@southernsun @inlife Thanks so much, works instantly! It's a pretty confusing concept from After Effects haha. Noticed this is explained in the Wiki too, thanks again!