-
SourceRectAtTime() for 2 lines of text with different sized Box
Hello everyone,
i’m working on a subtitle template and i’m having some trouble to have the desired render that i need.
basically it’s a sourcerectattime() process with two text line, and the boxes in the back should have the same size of the line, i did all my template but i’m stuck at the different size boxes, i only have one box, that is the length of my longest line.
i finished my template that way to show to my client, but he really wants the separate boxes.to explain my template :
my subtitle are on 2 text line, animated on Source text with a fading opacity at each key frame
i did expression on my text and boxes anchor point so i can change the alignement of my text and the box will stay at the same placesi have an expression in my anchor point :
a=thisComp.layer("Soustitre") .sourceRectAtTime() ;
Height=a.height;
Width=a.width;
Left=a.left;
Top=a.top;x=Left+Width/2;
y=Top+Height/2;[x,y]
and one in my opacity so my text fade before each key frame :
fadeTime = .3;txt = text.sourceText;
if (txt.numKeys > 0){
t = txt.nearestKey(time).time;
if (time < t)
ease(time,t-fadeTime,t,100,0)
else
ease(time,t,t+fadeTime,0,100);
}else
valuethen i created a shape layer box :
with an expression in my size, so it copy my text sizeand i added a controller for the padding :a=thisComp.layer("Soustitre") .sourceRectAtTime() ;Height=a.height;
Width=a.width;p=effect("Box Size") ("Curseur") ;
x=Width+p;
y=Height+p;[x,y]
and another one in my anchor point:a=thisComp.layer("Soustitre") .sourceRectAtTime() ;
Height=a.height;
Width=a.width;
Left=a.left;
Top=a.top;x=Width/-2-Left;
y=Height/-2-Top;[x,y]
and at least a fading expression on my box so it fade when the layer stop:
fadeIn = linear(time, inPoint , inPoint + .5, 0, 65)
fadeOut = linear(time, outPoint - .5,outPoint, 0, 65)
fadeIn - fadeOuti’ve fix my template, with multiple code on the internet , (thanks to this forum, adobe’s one and reddit, and of course Dan Ebbert)
i’ve seen that i’m not the only one looking for a hack on this, but never seen any solution so maybe any of you found and will be glad to share.Thanks to everyone having an idea to share, if you have any question don’t hesitate to ask.
have a good day
