ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

If xyz = inputValue then Do this until outputValue etc.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Andreas Wiens
If xyz = inputValue then Do this until outputValue etc.
on Dec 8, 2017 at 4:01:49 pm

Hey sorry if it was asked before, but i couldnt really find anything related.

Basicly i have been trying to play around with json files abit to speed up some processes regarding subtitles.

i have an in and outpoint in the json file for the subtitles and different languages aswell.

[
{
"in": 50,
"out": 80,
"Lan01": "lol rofl",
"Lan02": "cool",
"Lan03": "no please"
},
{
"in": 125,
"out": 150,
"Lan01": "exactlz",
"Lan02": "story",
"Lan03": "no no no"
},
{
"in": 200,
"out": 220,
"Lan01": "end what",
"Lan02": "bro",
"Lan03": "ok ok"
}
]

now i am trying to figure out if it is possible to work with only one text layer using an expression which reads the in and outPoints, then checks the current time, displays the desired language subtitle etc.

sorry for bad english

Cheers
andy


Return to posts index

Dan Ebberts
Re: If xyz = inputValue then Do this until outputValue etc.
on Dec 8, 2017 at 7:35:25 pm

That should work. How will the expression know which language to use?

Dan



Return to posts index

Andreas Wiens
Re: If xyz = inputValue then Do this until outputValue etc.
on Dec 11, 2017 at 10:42:00 am

Hey Dan,

thank you for replying (big fan - your posts here have been a life saver).

Well the language Part isnt really what bothers me. probably could just add a checkbox / slider for what ever language currently needed.

The thing is what im currently struggeling with is that i get all the arrays of subtitles displayed at the right frame.
Im not really familiar with all the functions in the expression language.

my though process for the expression is the following :

read json file
set a variable
if current time = inPoint then display the subtitle else empty value.
if current time = outPoint then empty value.

now i heard that expressions cant save data and this is the part im struggeling with.

since there will be multiple in/out points with an associated text.

so the expression needs to know when and what to display and when to not display it, based on the in/out Data and current time.

Cheers
Andy


Return to posts index


Dan Ebberts
Re: If xyz = inputValue then Do this until outputValue etc.
on Dec 11, 2017 at 2:26:02 pm

Something like this should display Lan01:


var myData = footage("test_json.json").sourceData;
txt = "";
for (i = 0; i < myData.length; i++){
if ((time >= myData[i].in) && (time < myData[i].out)){
txt = myData[i].Lan01;
break;
}
}
txt


Note that the times in the json file are interpreted as seconds. If you want it to be frames, it would be like this:


var myData = footage("test_json.json").sourceData;
txt = "";
for (i = 0; i < myData.length; i++){
if ((time >= framesToTime(myData[i].in)) && (time < framesToTime(myData[i].out))){
txt = myData[i].Lan01;
break;
}
}
txt



Dan



Return to posts index

Andreas Wiens
Re: If xyz = inputValue then Do this until outputValue etc.
on Dec 13, 2017 at 9:49:19 am

Thank you for your time Dan!
really appreciate it.

I will have a look, but it seems to work!

Cheers
Andy


Return to posts index

Andreas Wiens
Re: If xyz = inputValue then Do this until outputValue etc.
on Dec 13, 2017 at 2:18:19 pm

Ok everything works out the way it should, but i came across an issue i had before, when trying to read json files in after effects.

the expression seem to have problems with accents above letters (french language) - it simply does not display them.
i guess it doesnt support utf8. is there any solution to his ?

Cheers
Andy


Return to posts index


Dan Ebberts
Re: If xyz = inputValue then Do this until outputValue etc.
on Dec 13, 2017 at 5:52:14 pm

Can you post an example json file here?

Dan



Return to posts index

Andreas Wiens
Re: If xyz = inputValue then Do this until outputValue etc.
on Dec 19, 2017 at 12:12:54 pm

Hey Dan, sorry i just got back to replying.

"FRBR": "Vous bravez les conditions météo é",
its basicly cuts off the e's and displayes
"m t o ".

everything else works fine.


Cheers
Andy

{
"in": 447,
"out": 616,
"DE": "german text working fine",
"FRBR": "Vous bravez les conditions météo é",
},


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]