When I tried to follow you exactly typing the expression by hand it didn't work, so I checked the description and copied the one you provided. It worked! Not sure what I was missing in mine!
Okay I just tried again. I started with a brand new rectangle, and when it came to the expression I had better luck when I used the autofill suggestions when possible. It seemed to link things together properly. This is my first time doing an expression so I have NO idea what the proper way is. XD
Very helpful expression! The problem I'm currently facing is that when you move the text and box in the timeline, the timing of the box gets completely messed up for me and the box moves inbetween the text hold keyframes for some reason. I tried precomposing text and the box to move it but that doesnt fix the problem. I don't really know much about expressions but maybe it has to do with the .sourceRectAtTime command? Edit: I just found a workaround to not move the layers themselves, but dragging out the back and pulling in the front and then moving the keyframes to the correct timing. That kinda fixes it.
Great tutorial! So far, the only "problem" I'm facing is that the subtitles-box even shows a little square when the text is empty (includes no letters).. So when you want to have a "break" for a moment with the subtitles you would have to work around it.. (I know it's because of the additional space which is added to the size of the letters/text). I'm sure there is a way through expressions to tell it not to show a box whenever the text remains empty... unfortunately I'm not familiar enough with expressions.
I was having the same trouble and i didn't know how to solve it, so i asked it to ChatGPT and i can belive it but it solved that issue, change the code with this: Subtext = thisComp.layer("Subtitles"); textContent = Subtext.text.sourceText; if (textContent == " ") { [0,0] } else { TextWidth = Subtext.sourceRectAtTime(time).width+80; TextHeight = Subtext.sourceRectAtTime(time).height+30; [TextWidth, TextHeight] } Have the consideration that ( " " ) represent a space and not empty, because when i didn't have text what i did was create a space to create a keyframe. I hope it solve your problem too!
Lol no way GPTChat gave you that answer :)) You can make it even a little simpler. Add these 3 lines to your "Subtitles Box" layer opacity property: subs = thisComp.layer("Subtitles").text.sourceText; if (subs == "") 0 else 70 it checks the text value on your Subtitles layer and if its empty, sets box opacity to 0.
Hey, thanks a lot, nice and easy tutorial, tho I'm using it for an animated interface. I have animated text inside a button, which needs a minimum rectangle size. Could you think of a solution?
If this isn't working for you, here's something that helped me: Go to your background subtitle box layer, and make sure that every Scale or Size is set to 1920x1080, or 100%
Thank you, so well done. Subbed) How do I account for the parts of text that are below the centre like in "g" etc? They seem to make it not quite centred if you see what I mean.
Thanks Alex. Yeah that's a little annoying and I only noticed it myself after recording the tutorial. There's a couple of ways to fix it: 1. Use capitalized text. It will make all of your letters the same size. 2. You could turn off that Anchor Point expression and simply adjust your subtitles text position by hand. You'd also have to set a fixed height for Subtitles BG box expression "textHeight = 100;". This approach doesn't work with 2 lines of text. I'm sure there's a way to write an expression that looks at whether the line has any "g" or "l" type of characters that stick out either at the top or bottom, but that's a little too complex for the tutorial I wanted to share. Hope this helps.
thx fot the tut mate, is there an expression that makes the rectangle follows the text word by word I asked chat gpt for this but I keep getting errors please let me know if that's possible thanks again
I can't get it to work. The first line returns "object of type layer found where a property is needed" - don't really see, why a layer can't be assignable to a variable...
Late to the Party - but: Just ad keyframes with no text or a blank space in the textelement. You will have a small backround-box with the dimensions of your padding in the pauses. to get rid of them automatically i just use an expression to set opacity of the box-Layer to the Width of the text. It's not sophisticated but worked for me (subText = thisComp.layer("Subtitles"); transform.opacity = subText.sourceRectAtTime(time).width; )
Hi Eindrew9 its strange you say it doesn't work when you copy it to a new comp. I've tested it a couple of ways here and I can't see to find a way to break it. Could you send me your file to support@southeleven.com so I can take a look? When duplicating the two layers you have to update the first expression line on "Background Box 2" layer's "size" parameter. Change it from "subText = thisComp.layer("Subtitles Text");" to "subText = thisComp.layer("Subtitles Text 2");".
@SOUTH11_YT Hey, thanks for your tutorial! Do you know of any additonal code if I want the box to look more accurate for 2 lines with different width? E.g. Top line is shorter than the bottom line, ideally would want the box above to be shorter than the one at the bottom (rather than just a rectangular box)? I am ok if there is no additional leading from line 1 to line 2 excluding the box! lmao not sure if you know what I'm talking about.
Hmm weird - I can't seem to be able to reproduce this. But one thing that comes to mind is that your video comp might have a different framerate to the comp where you created your subtitles. If you paste the two layers into your video comp, text layer will have the keyframes set in between the frames and no exactly on them. You could try to shift them to exact frames manually and see if that fixes is?
subText = thisComp.layer("Subtitles"); textWidth = subText.sourceRectAtTime(time),width + 100; textHeight = subText.sourceRecAtTime(time),height + 40; [textWidth, textHeight] I'm getting an error with this, can anyone see what the issue is? Thanks
What’s the error saying? Is your subtitles text layer called “Subtitles”? Does the expression work if you just copy and paste it exactly as in description?
@@connorwarden1557 Glad to hear that. What was the problem? Could it be that you added a text box (you add it by clicking and dragging out a box using a text tool) instead of typing your text? There's no expressions on your text layer to affect how the text is displayed so I'm not sure why it would do that.
Great tutorial, I have a question I have this code for a subtitle text box : text=thisComp.layer(""); width=tex.sourceRectAtTime(time-tex.inPoint,true).width+45; myFade = 12; if ( marker.numKeys > 0){
I'd probably approach it using an array and do it something like this: // Vars subs = thisComp.layer("Subtitles").text.sourceText; subsText = thisComp.layer("Subtitles"); keyArray = []; //Create an array with all keyframe times for (i = 1; i < subs.numKeys+1; i++) { keyArray.push(subs.key(i).time); } //Transition for (i = 0; i < subs.numKeys-1; i++) { if (time>keyArray[i]) { transitionTime = keyArray[i+1] keyCur = keyArray[i] keyNext = keyArray[i+1]; } } //Set box width textWidthCur = subsText.sourceRectAtTime(keyCur).width + 100; textWidthNext = subsText.sourceRectAtTime(keyNext).width + 100; //Output textWidth = ease(time, transitionTime-0.2, transitionTime, textWidthCur, textWidthNext); textHeight = subsText.sourceRectAtTime(time).height + 40; [textWidth, textHeight] --------------------------------------------------------------------------------- You'd have to clean it up a little bit but if you paste it into your "Subtitles Box" layer, it will work. Not sure how you'd approach the text to create a smooth transition but please do share the finished project as I'd like to see how it turns out. All the best,
seeing some editor applications that are now very easy to use and many and fast to do updates, especially capcut.... then with this I can assume that Adobe is like a dusty book that is never updated and used...
This is the best, most straight foreward subtitle tutorial I've come across! Great work!!
Great tutorial, works so well. before I was resizing boxes manually
took me a while but worth it in the end, this tutorial saves me. Thank you sm ;D
Thank you so much!! it's more saving time using expression comparing to animating manually.
When I tried to follow you exactly typing the expression by hand it didn't work, so I checked the description and copied the one you provided. It worked! Not sure what I was missing in mine!
Okay I just tried again. I started with a brand new rectangle, and when it came to the expression I had better luck when I used the autofill suggestions when possible. It seemed to link things together properly. This is my first time doing an expression so I have NO idea what the proper way is. XD
@@deliberatevideo could be the capitalization of your text or missing punctuation
Thank you so much sir! I've been finding it for so long.
Thank you so much. This is exactly what I needed! T^T
Thank you! Straight forward end well explained! :)
El mejor tutorial que he visto para generar subtítulos en After Effects ^^
Very helpful expression! The problem I'm currently facing is that when you move the text and box in the timeline, the timing of the box gets completely messed up for me and the box moves inbetween the text hold keyframes for some reason. I tried precomposing text and the box to move it but that doesnt fix the problem.
I don't really know much about expressions but maybe it has to do with the .sourceRectAtTime command?
Edit: I just found a workaround to not move the layers themselves, but dragging out the back and pulling in the front and then moving the keyframes to the correct timing. That kinda fixes it.
Great tutorial! So far, the only "problem" I'm facing is that the subtitles-box even shows a little square when the text is empty (includes no letters).. So when you want to have a "break" for a moment with the subtitles you would have to work around it.. (I know it's because of the additional space which is added to the size of the letters/text). I'm sure there is a way through expressions to tell it not to show a box whenever the text remains empty... unfortunately I'm not familiar enough with expressions.
I was having the same trouble and i didn't know how to solve it, so i asked it to ChatGPT and i can belive it but it solved that issue, change the code with this:
Subtext = thisComp.layer("Subtitles");
textContent = Subtext.text.sourceText;
if (textContent == " ") {
[0,0]
} else {
TextWidth = Subtext.sourceRectAtTime(time).width+80;
TextHeight = Subtext.sourceRectAtTime(time).height+30;
[TextWidth, TextHeight]
}
Have the consideration that ( " " ) represent a space and not empty, because when i didn't have text what i did was create a space to create a keyframe.
I hope it solve your problem too!
Lol no way GPTChat gave you that answer :))
You can make it even a little simpler. Add these 3 lines to your "Subtitles Box" layer opacity property:
subs = thisComp.layer("Subtitles").text.sourceText;
if (subs == "") 0
else 70
it checks the text value on your Subtitles layer and if its empty, sets box opacity to 0.
When I move subtitles on the timeline or copy and paste to another composition, background rectangle doesnt work properly :(
Hey, thanks a lot, nice and easy tutorial, tho I'm using it for an animated interface. I have animated text inside a button, which needs a minimum rectangle size. Could you think of a solution?
Thanks for the tutorial , I'll try this.
What if I want to make a background rectangle to go along with the typewriter effect on words?
If this isn't working for you, here's something that helped me:
Go to your background subtitle box layer, and make sure that every Scale or Size is set to 1920x1080, or 100%
Make sure you delete the stroke or you will have an error
Thanks man, it helps me a lot
thanks a lot, very useful!
Thank you, so well done. Subbed)
How do I account for the parts of text that are below the centre like in "g" etc? They seem to make it not quite centred if you see what I mean.
Thanks Alex. Yeah that's a little annoying and I only noticed it myself after recording the tutorial. There's a couple of ways to fix it: 1. Use capitalized text. It will make all of your letters the same size. 2. You could turn off that Anchor Point expression and simply adjust your subtitles text position by hand. You'd also have to set a fixed height for Subtitles BG box expression "textHeight = 100;". This approach doesn't work with 2 lines of text.
I'm sure there's a way to write an expression that looks at whether the line has any "g" or "l" type of characters that stick out either at the top or bottom, but that's a little too complex for the tutorial I wanted to share.
Hope this helps.
thx fot the tut mate, is there an expression that makes the rectangle follows the text word by word I asked chat gpt for this but I keep getting errors please let me know if that's possible thanks again
how do i do if i don't want the box height to change? i only want the width to change.
I can't get it to work. The first line returns "object of type layer found where a property is needed" - don't really see, why a layer can't be assignable to a variable...
Thank you so much!
I do exactly what the tutorial says and copy the expressions but I keep getting errors :/
Same here
THANKS YOU YOU SAVE MY HEAVY LIFE , YOU ARE SUPERMAN !!!
thank you very much broo you really helped))
Hey, Just in case anyone did not know, Textbox 2 plugin is paid but can save you alot of time with many customizations.
Thanks Man!
Hey thank you for tutorial. What if I want pauses between text? I tried make more boxes with subtitles but it doesnt work.
Late to the Party - but: Just ad keyframes with no text or a blank space in the textelement. You will have a small backround-box with the dimensions of your padding in the pauses. to get rid of them automatically i just use an expression to set opacity of the box-Layer to the Width of the text. It's not sophisticated but worked for me
(subText = thisComp.layer("Subtitles");
transform.opacity = subText.sourceRectAtTime(time).width;
)
I'm stuck.. what did you just type on the first expression after typing sub Text min 5:39?
You should enter one of the expressions from video description.
hey! nice tutorial, but when I copy the layers to a different comp or duplicate them or whatever, it does not work anymore? why is that?
Hi Eindrew9 its strange you say it doesn't work when you copy it to a new comp. I've tested it a couple of ways here and I can't see to find a way to break it. Could you send me your file to support@southeleven.com so I can take a look?
When duplicating the two layers you have to update the first expression line on "Background Box 2" layer's "size" parameter. Change it from "subText = thisComp.layer("Subtitles Text");" to "subText = thisComp.layer("Subtitles Text 2");".
It's working for 1 line subtitle, Thanks! How about if we use 2 line subtitle?
Hi Dwi, yes that should work too. See at 8:21s mark where I show how to use it with multiple lines.
@SOUTH11_YT Hey, thanks for your tutorial! Do you know of any additonal code if I want the box to look more accurate for 2 lines with different width? E.g. Top line is shorter than the bottom line, ideally would want the box above to be shorter than the one at the bottom (rather than just a rectangular box)? I am ok if there is no additional leading from line 1 to line 2 excluding the box! lmao not sure if you know what I'm talking about.
WOW dude! For me, this is epic!
Thanks a lot bro
No problem ;)
My subtitles box is changing shape a fraction of a second before the text why is that?
same problem
It seems to work fine on a blank comp as in the video but as soon as it's placed on top of a footage file it fails?
@@27shearer good shout, i can troubleshoot it by creating another precomp for it but still it's off, but i can manual sort it.
Hmm weird - I can't seem to be able to reproduce this. But one thing that comes to mind is that your video comp might have a different framerate to the comp where you created your subtitles. If you paste the two layers into your video comp, text layer will have the keyframes set in between the frames and no exactly on them. You could try to shift them to exact frames manually and see if that fixes is?
Can i ask you ? What symbol u use “ Subtext (?) ?
Hi Muhd, I'm not sure I follow your question... Take a look at video description where I've added the expressions used in this demo.
@@SOUTH11_YT Ok great thank u .
how to make the rectangle change with words
You need add those two expressions found in the description.
thanks
You're welcome!
How if align right?
subText = thisComp.layer("Subtitles");
textWidth = subText.sourceRectAtTime(time),width + 100;
textHeight = subText.sourceRecAtTime(time),height + 40;
[textWidth, textHeight]
I'm getting an error with this, can anyone see what the issue is? Thanks
What’s the error saying? Is your subtitles text layer called “Subtitles”? Does the expression work if you just copy and paste it exactly as in description?
@@SOUTH11_YT Hey I've got it all going now, only issue is when the text goes to two lines instead of one, the box is offset?
@@connorwarden1557 Glad to hear that. What was the problem? Could it be that you added a text box (you add it by clicking and dragging out a box using a text tool) instead of typing your text? There's no expressions on your text layer to affect how the text is displayed so I'm not sure why it would do that.
@@SOUTH11_YT respect for replying to comments and helping 1.5 years later, nice video btw!
dose it works in crack version
Crack version of what?
❤
Remember to tell people to make sure they´ve got their text ´CENTRE ALIGNED´ before they try this.
bruv..it's not staying center alligned for a new subtitle keyframe
what to do :(
there are errors in my case
What errors are you getting?
sorry not working
What wasn’t working?
@@SOUTH11_YT that code in description. i wrote code in video after that works. wrong code in description.
Great tutorial, I have a question
I have this code for a subtitle text box :
text=thisComp.layer("");
width=tex.sourceRectAtTime(time-tex.inPoint,true).width+45;
myFade = 12;
if ( marker.numKeys > 0){
m = marker.nearestKey(time);
t = m.time;
d=linear(width,0,1400,45,1400);
if (t
I'd probably approach it using an array and do it something like this:
// Vars
subs = thisComp.layer("Subtitles").text.sourceText;
subsText = thisComp.layer("Subtitles");
keyArray = [];
//Create an array with all keyframe times
for (i = 1; i < subs.numKeys+1; i++) {
keyArray.push(subs.key(i).time);
}
//Transition
for (i = 0; i < subs.numKeys-1; i++) {
if (time>keyArray[i]) {
transitionTime = keyArray[i+1]
keyCur = keyArray[i]
keyNext = keyArray[i+1];
}
}
//Set box width
textWidthCur = subsText.sourceRectAtTime(keyCur).width + 100;
textWidthNext = subsText.sourceRectAtTime(keyNext).width + 100;
//Output
textWidth = ease(time, transitionTime-0.2, transitionTime, textWidthCur, textWidthNext);
textHeight = subsText.sourceRectAtTime(time).height + 40;
[textWidth, textHeight]
---------------------------------------------------------------------------------
You'd have to clean it up a little bit but if you paste it into your "Subtitles Box" layer, it will work. Not sure how you'd approach the text to create a smooth transition but please do share the finished project as I'd like to see how it turns out.
All the best,
@@SOUTH11_YT Thanks man
Yeah sure, i will share it with you when it is finished.
seeing some editor applications that are now very easy to use and many and fast to do updates, especially capcut....
then with this I can assume that Adobe is like a dusty book that is never updated and used...
Thank you so much!