ADOBE PREMIERE PRO: Tutorials Forum Articles Creative Cloud Debate

Subtitle solution After Effects MAC CS5 but javascript not working on PC

COW Forums : Adobe Premiere Pro

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Chris BoylanSubtitle solution After Effects MAC CS5 but javascript not working on PC
by on Dec 12, 2015 at 2:07:25 pm

Hi,

I work between Mac and PC and I've been using this javascript on the Mac to add subtitles from a text file using just markers on a text layer, it's pretty neat and was originally written by !Rocky. Fruitless searches for !Rocky's original PC version have lead me here. I have some programming knowledge but this is a head scratcher, are there any javascript experts out there who know how to tweak the script so it works on a PC once more? There seems to be a problem with the "else" command near the end.

{
// Subtitle generator by !Rocky
// modified by Colin Harman ( http://colinharman.com/ ) to work on a Mac
//
// 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();
}


Return to posts index

Walter SoykaRe: Subtitle solution After Effects MAC CS5 but javascript not working on PC
by on Dec 16, 2015 at 11:59:25 am

Chris, if you had posted this in the After Effects forum instead of the Premiere forum, I would have caught it days ago.

This code runs as-is on my PC here and works as expected; what's the problem you're seeing?

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2016 CreativeCOW.net All Rights Reserved
[TOP]