2DeadFrog Post - Subtitles on After Effects.

Subtitles in After Effects: A quick, easy and painless technique

Just picture this scenario: there are just 4 people in the editing room. The political marketer, the editor, the copywriter and the motion designer. They all are racing against the clock to finish the program and send it to the broadcaster, but there is a bottleneck in this process: generating subtitles in After Effects in an extremely quick manner! That’s what I’m about to teach you in this article.


I created a video tutorial to explain this technique, check it out!

The editor masterfully cuts all the scenes with his digital machete (commonly known as Razor Tool in Premiere, press “C” and check for yourself). The copywriter transcribes all the dialogues of the program as fast as she cans.

I’m the motion designer and, on my desk, I now have a program with approximately 12 minutes, to which I must generate subtitles. Time available to accomplish the task: 10 minutes, less than the video’s length.

Cold sweats run down everyone’s back. The rest of the team, approximately 30 professionals, between journalists, cameramen, photographers, among others, are kept outside the room without knowing what is going on. I get up after 6 minutes. The marketer’s left inferior eyelid starts to quiver involuntarily. I say that I’ll get a cup of coffee. The editor drops the Wacom pen into his mug. Then I say: People, it’s rendering now, I’ll have the subtitles ready to be embedded in 2 minutes! That means 2 minutes of free time to get some coffee.

Well, if you want to understand how it is possible, just download the free After Effects script at the end of this article and use it. But keep reading to learn the workflow.



This is a depiction of a political campaign that I was part of. During the day, I developed the graphical part, the motion graphics, the lower thirds. But when it was time to finish the program, I had to generate the video subtitles (subtitles indeed, embedded directly in the image, not a closed caption). In this context, I developed a very simple way to create subtitles in After Effects. I kept improving the project over the years, making it more practical. But the overtone of this article’s story has been adapted, as if I already used this final version, just to make it more didactic. How this method works? Expressions, as always.



During this campaign’s preparation, I settled with the editor that I would use the program’s final audio to generate subtitles with alpha channel in After Effects.

That way he could directly embed the video’s subtitle on the timeline of the political program and export it on real-time to tape (yes, back then, the remote programs were handed to broadcasters as DV tapes. “Upload issue” meant a delivery man crashed into the ground).

You will be able to use the text box directly on your project, the pre-render simplified our lives in that context.

The copywriter also got the audio and used it to write all the spoken text, creating the line breaks deemed necessary to make the subtitles in After Effects. Whenever there was a period without subtitles, she added a blank line to the document.

With the audio and transcript in hands, I past the text in a terx layer and drop the audio in the same composition in After Effects and did an audio preview (“.” on the keypad). I adjusted the preview’s frame-rate to twice the normal speed, taking half the time to listen to the whole program. While I listened to it, I kept generating markers in the text layer for each line break (using “*” on the keypad). At the end of this process, the subtitles were ready to be rendered.

The task of separating the text and spread it on the right time frames was carried out by the expressions. But in your case, you’ll use my script to make it even faster.



I’m not an expert on expressions, but with time I learned how to read them and I’m now capable of understanding most of what they mean. By combining this with Google (which usually takes me to an answer of Dan Ebberts in a Creative Cow article) I can work things out. I think it’s really important to invest time in studying them, my knowledge is not that deep but they helped me immensely during the creation of products like Design and Motion Character Kit, Simple Car Rig, among others products.

To create this subtitle soluction, I used the following expressions:



This expression is amazing and quite helpful. I learned how to use it in this Zack Lovatt’s post. It basically breaks any text in parts, using whatever character you prefer to.

In Zack’s article, he relies on it to extract the composition name from After Effects, the title and subtitle of one lower third. In my case, I use it to break the subtitle’s line. The syntax is very simple:


Translating this into proper English, it means:

Grab the content of this text (text.sourceText), break it into different blocks every time the character “/” appears (split(‘/’). Please just show me block 5 (replace the i with any number). Thanks!


2DeadFrog After Effects: Subtitle split expression


But how can we make the right block appear in the exact moment, like the marker?


Counting markers

If I could create an expression that counted the number of markers that I have in a layer as time goes by, I would solve this issue right away. I couldn’t make that. But Walter Soyka did it and explained how in this Creative Cow post. For him, a digital scoreboard of ice hockey. For me, the solution to my problems.

m = thisLayer.marker;
i = m.nearestKey(time).index;

if (m.nearestKey(time).time > time){ i--;}
if (i < 1) { i = 1};

This expression is much more difficult to read, but it basically keeps an envelope called “i”, the reference number of each marker that we pass through. If the last marker that we pass through is the second, then “I” will be 2. If it’s the fifth, “I” will be 5.


2DeadFrog After Effects: Subtitle markers counter expression


With this, you probably have already figured how both expressions work together, right? Every time we pass through a marker, the split expression will take a look on the envelope to see the number it holds, and then it shows us the corresponding text block at the right time.

But what if the number of counted blocks is smaller than the number of markers, that will probably create an error in the expression, isn’t it?


try {code} catch(err) {code}

That was when Thomas Euvrie helped me. In this post, he happily explains that After Effects CC 2015 (13.5) ignores simple expression issues without disabling them. The only thing that pops up is the orange banner that we are used to already. Remember when there was a pop-up on the screen playing chord.wav at full volume?


2DeadFrog After Effects: Expression error


But I prefer to have no notifications at all, in this case we just have to use the following expression:

try {code1} catch(err) {code2}

Translation: Try code 1, if not successful, use code 2. Simple and easy.


Final Code

Gathering all this, we just have to apply the following code into the Souce Text of your text box:

m = thisLayer.marker;
i = m.nearestKey(time).index;

if (m.nearestKey(time).time > time){ i--;}
if (i < 1) { i = 1};

try {text.sourceText.split('/')[i]} catch(err) {''}



If you are not so good with expressions in After Effects, I made this script to you. With only one click, you apply the expression above in your text layer.

Just download, install it, select your text layer and click in “SUBTITLE”.

Click to download the Subtitles in After Effects script

Follow the aforementioned workflow to work with your subtitles in After Effects. Use the formatting you want, you can change fonts, colors, drop shadows, without any limits. Remember to take the contrast into account to allow a good readability on any background, I tend to opt for a yellow font, with black contour and drop-shadow, much in the vein of VHS subtitles.


Enough with the suffering of having to duplicate layers to create subtitles in After Effects, or using Premiere’s character generator. Let expressions solve this problem for you and go make a cup of coffee while the rendering takes place. Get a better grasp of how this works, download the Subtitle in After Effects script.

Leave your experience with subtitles in the comment section below. I’m sure that much has happened already.