Best Way to Template Subtitle Track
-
Hi,
I am exporting a video in 20 different languages, each of which has subtitles in that language.
I’m trying to figure out the best way to Template a subtitle track just like I am doing with graphics, text layers, etc. The client has provided .srt files so I’m hoping there’s a way to leverage that data.
Has anyone done something like this?
-
The good news is that it can be done! However, it’s a bit trickier than your average text layer swap. Basically, you’ll need to rename the files to swap the file extension from
.srt
files to.jsx
files and then import one of them into AE as if it is a normal footage layer. After you’ve imported the file, you’ll want to add it to the timeline and then map the data from the.jsx
to a text layer using an AE Expression. Once all that is working, it should be possible to use Templater to swap between the.jsx
versions of the.srt
files in order to swap between different sub tracks.For a sample, take a look at this example project on our GitHub repo:
The project contains a sample aep file that has everything already set up. Simply point the Data option to the “Subtitle Swap Data.json” file and direct the Footage directory to the
subtitle-swap
folder.From there, you should be able to swap between the three data points. The video footage is also swapped and Time Sculpted to set the duration of the main comp to be the same as the duration of the video clip.
Hopefully, that’s enough to get you started, but if you run into any trouble, let us know, and we’ll do what we can to help.
Edit: for those who come to this later, please pay attention to the line endings in the repo’s
JSX
(SRT) files when you download or clone from GitHub. Depending on your OS, they may be incorrect. These files were created withCRLF
(Windows) line endings and will work on Windows if you clone with a git management app. If you downlead the zip, they may be inLF
(Unix). On MacOS, the OS may be expectingCR
(Macintosh) line endings. It’s a difficult thing to manage cross-platform compatibility, so just be mindful if you experience issues. -
@jon Thank you so much! I am going to begin experimenting with this today.
-
@jon Hey Jon. So this is looking great so far. Only thing I’m confused about from the sample project is the subs aren’t timed out. It’s just one big text file…
-
@scainopictureman it may be possible that the expression on the text layer isn’t working correctly for you? I’ve re-verified that it’s still working correctly in AE 2023. Which version of After Effects are you using? What language is set for AE and your operating system?
-
@jon Thanks so much for your prompt reply. If we get this working, it will be a game changer for me.
I am on After Effects 23.2.1. The language on my Windows machine is US English.
I’m not sure how to check language on After Effects but it all looks like US English to me.
The swapping of the layers is working fine, so it’s just that formatting issue we need to crack. -
@jon So interestingly enough. When I swapped the sample .jsx files for some of my own files, it worked! THANK YOU!
-
@scainopictureman glad to hear it’s working! That is odd behavior and I’m not sure why it wouldn’t just work right away.
-
I’m having the same issue
-
I’m on AE 23.2.1
I believe I’m on the latest version of Templater, but am not 100% sure
-
I’m seeing some odd weird green text, and the entire expressions box appears to be glitching
https://www.jotform.com/uploads/AlexaSports/222508108729053/5577826774387959455/Screenshot 2023-04-19 at 11.50.37 PM.png
-
@ben-forman Looks like that second screenshot isn’t coming through due to spaces in the URL.
Does advancing the preview to the next data point or a different subtitle file (srt -> jsx) resolve the expression not completing its calculation?
-
After doing some troubleshooting, it seems like the behavior we’re seeing here is the result of the encoding format of the .jsx subtitles files in the project. If we open the Lockdown-Walkthrough.jsx, Templater-Intro.jsx, and Templater-Walkthrough.jsx files in an advanced text editor like Notepad++, it should be possible to change the encoding from Unix (LF) to Windows (CR LF) to make the example files read correctly on Windows-based systems.
Or, as @scainopictureman did in their previous reply, you could always replace the existing .jsx files with properly formatted ones to verify that the expression works with files with the correct text encoding.
Unfortunately, it seems as though GitHub converts everything to Unix (LF) encoding when files are downloaded through the website interface, so there’s not much we can do on that side, but at least we know what’s causing the error in After Effects.
Thanks!
-
I’m on a Mac, does the same advice still apply? I need to change the encoding of the JSX? Can I use sublime?
-
Note my issue happening with SRT files I got from other places (not the github ones)
-
@ben-forman There appear to be lots of ‘Save with Encoding’ options, the first few I’ve tried didnt work though.
-
@jeff said in Best Way to Template Subtitle Track:
@scainopictureman Can you post the jsx file that worked here?
-
@ben-forman said in Best Way to Template Subtitle Track:
I’m on a Mac, does the same advice still apply? I need to change the encoding of the JSX? Can I use sublime?
So the line endings on Mac might work best as CR (rather than CRLF or LF). Sublime should let you change the line endings, too.
@ben-forman said in Best Way to Template Subtitle Track:
@ben-forman There appear to be lots of ‘Save with Encoding’ options, the first few I’ve tried didnt work though.
The encoding should be utf-8.
-
@jon said in Best Way to Template Subtitle Track:
So the line endings on Mac might work best as CR (rather than CRLF or LF). Sublime should let you change the line endings, too.
Can you clarify what this means? Am I changing characters? Changing encodings?
-
@ben-forman said in Best Way to Template Subtitle Track:
@jon said in Best Way to Template Subtitle Track:
So the line endings on Mac might work best as CR (rather than CRLF or LF). Sublime should let you change the line endings, too.
Can you clarify what this means? Am I changing characters? Changing encodings?
LF
,CR
, andCRLF
are platform-specific “line-endings”—they tell the OS where a given line of text or code ends and a new one starts. The behavior where it was displaying all of the subtitle text at once is because AE and the OS aren’t correctly interpreting where each line ends.UTF-8 is a text character encoding—numerical representations of a graphical character/shape. There are also others like ASCII, UTF-16.
The files in the GitHub repo are already UTF-8. When I created them on Windows, the files had CRLF line endings, but git automatically converted them to LF line endings upon uploading.
I am on Windows and an older version of Sublime, but this is what it looks like on my menu. Save after changing.