<p>As I've <a href="http://blob.pureandapplied.com.au/using-data-from-an-external-file-to-drive-expressions/" rel="nofollow noreferrer">written on my blog</a>, you can use the function <code>evalFile</code> to load the contents of an external file as data or executable code.</p>

<p>So if you have a file called <code>titles.txt</code> that looks like this</p>

<pre class="lang-js prettyprint-override"><code>var titles={
    {startTime:1.23, endTime:2.23, textContent:"this is the first subtitle"},
    {timestamp:2.34, endTime:3.45, textContent:"this is the second subtitle"},
    {timestamp:4.56, endTime:5.55, textContent:"and so on…"}
}
</code></pre>

<p>…you can evaluate it as part of the source of the expression, so that the <code>titles</code> array is now available to the expression.</p>

<p>So you could do something like this with the source text property of a text layer:</p>

<pre class="lang-js prettyprint-override"><code>try{
    myPath = “/path/to/my/titles.txt”; //obviously the path to the file
    $.evalFile(myPath);
    for (var i=0; i &lt; titles.length; i++){
       if (time &gt; titles[i].startTime &amp;&amp; time &lt; titles[i].endTime){
           titles[i].textContent;
       } else { ""; } //blank text
 }catch(err){
 “ERROR”;
} 
</code></pre>

<p>What that does is:</p>

<ul>
<li>load up the subtitles file, </li>
<li>scan through the titles and look at each one to see if the current time is between its start and end points</li>
<li>if the time is right for the subtitle to display then it sets the source text to the subtitle content, if not sets it to a blank string.</li>
</ul>

<p>Other layers could use the startTime and endTime variables to drive other properties such as opacity or anything else you can animate.</p>

<p>If your subtitle time stamps are represented as smpte timecode you'll have to add a converter to the expression. There's one <a href="https://stackoverflow.com/a/31385814/432987">here</a>.</p>

<p>You can use a capable text editor (notepad++, atom, sublime text, vim etc) to reformat the subtitles file, or you could use JS text processing tools (eg. regex, string.split, string.replace etc) in the script to parse the subtitles file. I'd recommend against the latter, they're going to be a lot slower. Remember that the expression is evaluated <strong>every time the frame is rendered</strong>, which includes reading the subtitles file from disk. If you have motion blur on, that could mean dozens of times each frame.</p>

CC BY-SA 3.0
2017-09-17T10:44:19.613Z
Thank you for your help.
I just wanted to make several lower thirds and apply them over (30 or 50) stamps which strings starts by [#] (symbol associated with first lower third) and then I apply second lower third to all stamps which strings starting with [$] (symbol associated with second lower third). Please see screenshot above.
In your code, I do not see how to do that (search for strings starting with [#] or [$]). I am wrong ? Sorry. As you see, English is not my first language.
Question
CC BY-SA 3.0
2017-09-18T03:34:56.213Z
Just save out your subtitles as an srt or whatever, then using a text editor like the ones I mentioned (all free) reformat them so that they look like the example above. You can use find-and-replace and regular expressions. You could add code to the expression that looks for the symbol, javascript has lots of string processing tools, most of which work in expressions (though they're not documented), but you'd be better off doing it in a text editor.
stib
CC BY-SA 3.0
2017-09-17T08:54:35.420Z
2017-09-17T08:54:35.420Z
stib
<p>Check out Marker Remap at www.aescripts.com/marker-remap . It takes the principles you mention above and adds a powerful After Effects panel to control marker additions and timing. You won't be able to customize it to your tags, but I think it offers the functionality you're looking for.</p>

CC BY-SA 4.0
2018-11-09T14:12:05.327Z
2018-11-09T14:12:05.327Z
sakeferret
<p>I need a professional advice for self-assessing among students. I am searching for a tool (script or scripts) that helps annotating very long videos in After Effects. I also would like to automate the process without repeating myself. </p>

<p>I have long speeches (narrations) of students with subtitles. Subtitles are edited in Subtitle Edit. In Subtitle Edit at the beginning of some words or sentences I add symbols like <strong>[#]</strong> or <strong>[$]</strong>.  After importing video and subtitles (<strong>pt_ImportSubtitles</strong>) with added <strong>[#]</strong> and <strong>[$]</strong> symbols I would like a specific lower third (simple text annotation or feedback) to be automatically activated (appeared on screen) (for 3 sec) for each imported word or group of words (marker or timestamp) with specific symbols.</p>

<p>Let us say that I have two lower thirds. First lower third is associated with words starting with а [#] (valid argument ) symbol and other set of words are associated with any words starting with [$] (invalid argument).</p>

<p>Examples 
[#] Moscow is the capital of Russian Federation
[$] Moscow is not a capital of Russian Federation</p>

<p><a href="https://i.sstatic.net/dwORP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dwORP.png" alt="ScreenShot of Subtitle Edit"></a></p>

<p>If <strong>[#]</strong> is repeated 30 times then the firt lower third must also be appeared 30 time. Same logic is for <strong>[$]</strong> symbol. </p>

<p>Texts for lower thirds preferably must be stored outside of AE in a spreadsheet for example (<strong>Text2Spreadsheet</strong>)</p>

<p>Please let me know if a tool (script or a set of scripts) that I am searching is indeed exists or not.
If not. How can I do it manually with scripts that I mentioned above ?
Thank you all</p>

CC BY-SA 3.0
2017-09-16T13:54:38.803Z
This can be done with scripting, but I doubt there's already a script that does what I think you want. Why not separate the subtitle process and the lower third process, it would make it much simpler.
stib
CC BY-SA 3.0
2017-09-16T18:49:42.163Z
Lower thirds are completely speared from imported subtitles (timestamps) I just use subtitles timestamps (markers) to trigger lower thirds to be appeared when it is needed.
Question
CC BY-SA 3.0
2017-09-16T19:07:27.263Z
Sorry. Not all subtitles timestamps but subtitles containing symbols like: # and & only. In the beginning of certain subtitles.
Question
<after-effects><subtitles><after-effects-expressions><automation><after-effects-scripting>
After Effects automation and annotation tools (scripts) for student work
Question
# After Effects automation and annotation tools (scripts) for student work

(Asked by: username_0 on 2017-09-16)

I need a professional advice for self-assessing among students. I am searching for a tool (script or scripts) that helps annotating very long videos in After Effects. I also would like to automate the process without repeating myself.

I have long speeches (narrations) of students with subtitles. Subtitles are edited in Subtitle Edit. In Subtitle Edit at the beginning of some words or sentences I add symbols like **[#]** or **[$]**. After importing video and subtitles (**pt\_ImportSubtitles**) with added **[#]** and **[$]** symbols I would like a specific lower third (simple text annotation or feedback) to be automatically activated (appeared on screen) (for 3 sec) for each imported word or group of words (marker or timestamp) with specific symbols.

Let us say that I have two lower thirds. First lower third is associated with words starting with а [#] (valid argument ) symbol and other set of words are associated with any words starting with [$] (invalid argument).

Examples
[#] Moscow is the capital of Russian Federation
[$] Moscow is not a capital of Russian Federation

[![ScreenShot of Subtitle Edit](https://i.sstatic.net/dwORP.png)](https://i.sstatic.net/dwORP.png)

If **[#]** is repeated 30 times then the firt lower third must also be appeared 30 time. Same logic is for **[$]** symbol.

Texts for lower thirds preferably must be stored outside of AE in a spreadsheet for example (**Text2Spreadsheet**)

Please let me know if a tool (script or a set of scripts) that I am searching is indeed exists or not.
If not. How can I do it manually with scripts that I mentioned above ?
Thank you all

**Tags:** after-effects, subtitles, after-effects-expressions, automation, after-effects-scripting

> **Comments:**
> **username_1**: This can be done with scripting, but I doubt there's already a script that does what I think you want. Why not separate the subtitle process and the lower third process, it would make it much simpler.  
> **username_0**: Lower thirds are completely speared from imported subtitles (timestamps) I just use subtitles timestamps (markers) to trigger lower thirds to be appeared when it is needed.  
> **username_0**: Sorry. Not all subtitles timestamps but subtitles containing symbols like: # and & only. In the beginning of certain subtitles.  

---

## 2 answers

### Answer by username_1 on 2017-09-17. Score: 0 | Accepted answer

As I've written on my blog, you can use the function evalFile to load the contents of an external file as data or executable code.
So if you have a file called titles.txt that looks like this
var titles={
    {startTime:1.23, endTime:2.23, textContent:"this is the first subtitle"},
    {timestamp:2.34, endTime:3.45, textContent:"this is the second subtitle"},
    {timestamp:4.56, endTime:5.55, textContent:"and so on…"}
}

…you can evaluate it as part of the source of the expression, so that the titles array is now available to the expression.
So you could do something like this with the source text property of a text layer:
try{
    myPath = “/path/to/my/titles.txt”; //obviously the path to the file
    $.evalFile(myPath);
    for (var i=0; i < titles.length; i++){
       if (time > titles[i].startTime && time < titles[i].endTime){
           titles[i].textContent;
       } else { ""; } //blank text
 }catch(err){
 “ERROR”;
} 

What that does is:

load up the subtitles file, 
scan through the titles and look at each one to see if the current time is between its start and end points
if the time is right for the subtitle to display then it sets the source text to the subtitle content, if not sets it to a blank string.

Other layers could use the startTime and endTime variables to drive other properties such as opacity or anything else you can animate.
If your subtitle time stamps are represented as smpte timecode you'll have to add a converter to the expression. There's one here.
You can use a capable text editor (notepad++, atom, sublime text, vim etc) to reformat the subtitles file, or you could use JS text processing tools (eg. regex, string.split, string.replace etc) in the script to parse the subtitles file. I'd recommend against the latter, they're going to be a lot slower. Remember that the expression is evaluated every time the frame is rendered, which includes reading the subtitles file from disk. If you have motion blur on, that could mean dozens of times each frame.

> **Comments:**
> **username_0**: Thank you for your help. I just wanted to make several lower thirds and apply them over (30 or 50) stamps which strings starts by [#] (symbol associated with first lower third) and then I apply second lower third to all stamps which strings starting with [$] (symbol associated with second lower third). Please see screenshot above. In your code, I do not see how to do that (search for strings starting with [#] or [$]). I am wrong ? Sorry. As you see, English is not my first language.  
> **username_1**: Just save out your subtitles as an srt or whatever, then using a text editor like the ones I mentioned (all free) reformat them so that they look like the example above. You can use find-and-replace and regular expressions. You could add code to the expression that looks for the symbol, javascript has lots of string processing tools, most of which work in expressions (though they're not documented), but you'd be better off doing it in a text editor.  

---

### Answer by username_2 on 2018-11-09. Score: 0

Check out Marker Remap at www.aescripts.com/marker-remap . It takes the principles you mention above and adds a powerful After Effects panel to control marker additions and timing. You won't be able to customize it to your tags, but I think it offers the functionality you're looking for.


---

