-- ********** bfTitleBatch ********** -- (C)2006 by Blazej Floch - Mail: labs bfloch com -- More info at http://labs.bfloch.com -- Version: iVerMajor = 0 iVerMinor = 5 -- Usage: -- You need two, or one composition. -- At least one should have both txtTitle -- and txtSubtitle named texttools and -- svOutput named saver. -- Use the format: -- [TITLE] -- Title -- Subtitle -- -- [TITLE] -- ... -- for your Titlelist. -- -- -- ***** TODO ***** -- Dateinamen parser von Title und diesen für -- Compnamen und Frame Verzeichnis benutzen. -- ****************************************** fusion = Fusion("localhost") composition = fusion:GetCurrentComp() SetActiveComp(composition) ret = composition:AskUser("bfTitleBatch", { {"Information", "Text", Wrap=true, Default="(C)2006 by Blazej Floch - Mail: labs bfloch com", ReadOnly=true, Lines=1}, {"Usage", "Text", Wrap=true, Default="You need two, or one composition. At least one should have both txtTitle and txtSubtitle named texttools and svOutput named saver. Use the format:\n[TITLE]\nTitle\nSubtitle\n\n[TITLE]\n...\n for your Titlelist.", ReadOnly=true}, {"Titlelist", "FileBrowse", Default="C:\\titles.txt"}, {"Title Composition", "FileBrowse", Default="C:\\Title.comp"}, {"Subtitle Composition", "FileBrowse", Default="C:\\Subs.comp"}, {"Composition File Name", "Text", Default="comp_", Lines=1}, {"Composition Directory", "PathBrowse", Default="C:\\Compo\\"}, {"Frame File Name", "Text", Default="frame_", Lines=1}, {"Frame Directory", "PathBrowse", Default="C:\\Output\\"} }) if ret == nil then return (10) end print (string.format("\n\n********** milTitleBatch v%d.%d **********", iVerMajor, iVerMinor)) if fileexists(MapPath(ret["Titlelist"])) == true then fh, errormessage = io.open(MapPath(ret["Titlelist"]), "r+") else print ("File not found: "..MapPath(ret["Titlelist"])) return (10) end if not fh then print (errormessage) return (10) end tTitlelist={} tSubtitlelist={} count = 0 -- 0 = Header -- 1 = Title -- 2 = Subtitle bNext = 0 print "***** Reading Titlelist..." line = fh:read("*l") while line do if line ~= "" then if string.sub(line, 1, 7) == "[TITLE]" then print ("") count= count + 1 bNext = 1 elseif bNext == 1 then print (string.format ("Title:\t%s", line)) tTitlelist[count] = line bNext = 2 elseif bNext == 2 then print (string.format (" -Sub:\t%s", line)) tSubtitlelist[count] = line bNext = 0 end end line = fh:read("*l") end iTitleLen = table.getn(tTitlelist) print (string.format("\n***** ...done reading %i Title(s)", iTitleLen)) compTitle = fusion:LoadComp(ret["Title Composition"]) compSubtitle = fusion:LoadComp(ret["Subtitle Composition"]) rm = fusion.RenderManager for i = 1, iTitleLen, 1 do if (tSubtitlelist[i] ~= nil) then SetActiveComp(compSubtitle) txtSubtitle.StyledText = tSubtitlelist[i] else SetActiveComp(compTitle) end txtTitle.StyledText = tTitlelist[i] curSaveDir = MapPath(string.format("%s%04d", ret["Frame Directory"], i)) os.execute("mkdir "..curSaveDir) curSaveFile = string.format("%s%s%s%s", curSaveDir, "\\", ret["Frame File Name"], ".tga") curCompFile = MapPath(string.format("%s%s%04d%s", ret["Composition Directory"], ret["Composition File Name"], i, ".comp")) svOutput.Clip = curSaveFile if (tSubtitlelist[i] ~= nil) then compSubtitle:Save(curCompFile) else compTitle:Save(curCompFile) end rm:AddJob(curCompFile) end compSubtitle:Close() compTitle:Close() fusion:ToggleRenderManager()