介绍
选择所有合成,单击创建按钮,即可在所有合成左下角加个时间码。
具体位置啥的、字体、字体大小自己改
源码
* https://www.yuelili.com/?p=18016
*/
var panelGlobal = this;
var main = (function () {
/*
Code for Import https://scriptui.joonas.me — (Triple click to select):
{"activeId":0,"items":{"item-0":{"id":0,"type":"Dialog","parentId":false,"style":{"enabled":true,"varName":"main","windowType":"Palette","creationProps":{"su1PanelCoordinates":false,"maximizeButton":false,"minimizeButton":false,"independent":false,"closeButton":true,"borderless":true,"resizeable":true},"text":"合成批量加时间码","preferredSize":[0,0],"margins":16,"orientation":"column","spacing":10,"alignChildren":["center","top"]}},"item-1":{"id":1,"type":"Button","parentId":0,"style":{"enabled":true,"varName":"time_code_btn","text":"加时间码","justify":"center","preferredSize":[0,0],"alignment":null,"helpTip":null}}},"order":[0,1],"settings":{"importJSON":true,"indentSize":false,"cepExport":false,"includeCSSJS":true,"showDialog":true,"functionWrapper":true,"afterEffectsDockable":true,"itemReferenceList":"None"}}
*/
// MAIN
// ====
var main = (panelGlobal instanceof Panel) ? panelGlobal : new Window("palette", undefined, undefined, {});
if (!(panelGlobal instanceof Panel)) main.text = "合成批量加时间码";
main.orientation = "column";
main.alignChildren = ["center", "top"];
main.spacing = 10;
main.margins = 16;
var time_code_btn = main.add("button", undefined, undefined, { name: "time_code_btn" });
time_code_btn.text = "加时间码";
time_code_btn.onClick = time_code_it
// 获取时间信息
function get_time(comp) {
s1 = comp.duration;//获取时间
s2 = comp.frameRate;//获取帧数率
s = (Number(s1 * s2)) + 1;
var a, b, c, d;
a = parseInt((s - 1) / 24);
b = "s+";
c = (s - 1) % 24;
d = "帧";
return a + b + c + d
}
// 主函数
function time_code_it() {
var selItems = app.project.selection
if (selItems.length == 0) {
alert("请在项目面板至少选择一个合成")
} else {
app.beginUndoGroup("Add 持续时间");//记录撤销
// 循环选中的项目
for (i = 0; i < selItems.length; i++) {
// 判断项目是否为合成
if (selItems[i] instanceof CompItem) {
// 获取合成时间
var time_txt = get_time(selItems[i])
var textLayer = selItems[i].layers.addText(time_txt);//文本显示格式为## s + ## 帧
textLayer.position.setValue([125, 1000]);//位置修改
textLayer.property("transform").property("Scale").setValue([200, 200]);//字符放大
var ramp = textLayer.effect.addProperty("ADBE Fill")//填充效果
ramp(3).setValue([1, 0, 0]);//字符颜色
}
}
app.endUndoGroup() //撤销结束
}
}
main.layout.layout(true);
main.layout.resize();
main.onResizing = main.onResize = function () { this.layout.resize(); }
if (main instanceof Window) main.show();
return main;
}());