How to subtitle in After Effects

Posted by on May 5, 2011 in After Effects, code, how to | One Comment

To subtitle in After effects, use the script linked below.

http://www.ithowto.ro/2008/12/adobe-after-effects-subtitle-script/

{
	//	Subtitle generator by !Rocky  http://www.ithowto.ro/2008/12/adobe-after-effects-subtitle-script/
        //     http://vimeo.com/rawkeh
	// 
	//	modified by Colin Harman ( http://colinharman.com/ ) to work on a Mac
	//
	//     modified by Oliver to work with CS5
	// 
	//	Save this code as
	//	"subtitles.jsx"
	//
	//	Create a text file with your subtitles.
	//	Each line of text is one on-screen line.
	//	To have several lines on-screen at the same time,
	//	simply separate them with a pipe ( | ) character.
	//	eg "Character 1 talks|Character 2 interrupts"
	//
	//	Create a new text layer in your comp, adjust its position,
	//	make sure the text's centered, so it looks nice
	//	Add markers (Numpad *) where each subtitle line must be shown/hidden.
	//	With the text layer selected, run the script, and select the subtitles file.
	//	Enjoy!

	function makeSubs() {
		var layer = app.project.activeItem.selectedLayers[0];

		if (layer.property("sourceText") != null) {
			var textFile = File.openDialog("Select a text file to open.", "");
			if (textFile != null) {
				var textLines = new Array();
				textFile.open("r", "TEXT", "????");

				while (!textFile.eof)
					textLines[textLines.length] = textFile.readln();

				textFile.close();

				var sourceText = layer.property("sourceText");
				var markers = layer.property("marker");

				for (var i = sourceText.numKeys; i >= 1; i--)
					sourceText.removeKey(i);

				var line = 0;
				var subTime, subText;
				for (var i = 1; i <= markers.numKeys; i++) {
					subTime = markers.keyTime(i);
					sourceText.setValueAtTime(0, " ");

					if ((i % 2) == 0) {
						subText = " ";
					}
					else {
						subText = textLines[line].replace("|", "\x0d\x0a");
						line++;
					}
					sourceText.setValueAtTime(subTime, new TextDocument(subText));
				}
			}
		}
	}
	makeSubs();
}

Email this to someoneTweet about this on TwitterShare on FacebookShare on Google+Share on LinkedInShare on StumbleUponShare on RedditDigg this

1 Comment

  1. ThomasSaboCharmsareknownasmuch
    March 16, 2013

    hey there and thank you for your info

Leave a Reply