{ // Subtitle generator by !Rocky. // modified by Ryan Webb (http://ryanwebb.com/) to become even more pant-wettingly useful. // // Save this code as // "subtitles.jsx" // // Create a text file with your subtitles. // The first line needs to read "translations = marker / timecode / decimal" depending on your input. // 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" // For timecode and decimal have the in/out time for each subtitle above the line of text. // eg "00:02:15 - 00:08:30 // this is an awesome subtitle script" // // Create a new text layer in your comp, adjust its position, // make sure the text's centered, so it looks nice. // If you are using the marker option, add markers (Numpad *) where each subtitle line should be shown/hidden. // // With the text layer selected, run the script, and select the subtitles file. // Enjoy! var layer = app.project.activeItem.selectedLayers[0]; var sourceText = layer.property("sourceText"); var textLines = new Array(); makeSubs(); function makeSubs() { if (layer.property("sourceText") != null) { var textFile = File.openDialog("Select a text file to open.", ""); if (textFile != null) { textFile.open("r", "TEXT", "????"); while (!textFile.eof) textLines[textLines.length] = textFile.readln(); textFile.close(); for (var i = sourceText.numKeys; i >= 1; i--) sourceText.removeKey(i); var z = textLines[0].split("="); z[1] = z[1].replace(/^\s+|\s+$/g, "") ; switch(z[1]) { case "decimal": decimalInterpret(); break; case "timecode": timecodeInterpret(); break; case "marker": markerInterpret(); break; } } } } function decimalInterpret() { var decimalArray = new Array(); var count = 1; for(var i=0; i<=textLines.length; i++) { if((i+1)%3 == 0) { var x = textLines[i].split("-"); for(var y=0; y