Using script to sync comps workAreaDuration
I have a special requirement in my work that I need to resize a batch of videos and add EndingCard for output.
However, the length of each video is different, so I made a script to synchronize the work area end time of each composition.
The first version of my script has no problem. It can directly synchronize the duration of all composition work areas.
function syncCompOutPoints() {
var rawCompNames = ["Raw Comp"];
var targetCompNames = ["Render 1080*1080 Target01","Render 1080*1080 Target02","Render 1080*1920 Target01","Render 1080*1920 Target02","Render 1920*1080 Target01","Render 1920*1080 Target02"]
var targetDuration = null;
var foundTargetComp = false;
for (var i = 1; i <= app.project.items.length; i++) {
var item = app.project.items[i];
if (item instanceof CompItem && rawCompNames.indexOf(item.name) >= 0) {
if (targetDuration == null || item.workAreaDuration < targetDuration) {
targetDuration = item.workAreaDuration;
}
foundTargetComp = true;
}
}
if (foundTargetComp) {
for (var i = 1; i <= app.project.items.length; i++) {
var item = app.project.items[i];
if (item instanceof CompItem && targetCompNames.indexOf(item.name) >= 0) {
item.workAreaDuration = targetDuration + 4;//add EndingCard's duration
}
}
} else {
alert("Failed to Find Raw Comp");
}
}
However, the second version of the script I wanted to help me synchronize the composition time by adjusting the composition marker. This script did not work.
function syncCompOutPoints() {
var rawCompNames = ["Raw Comp"];
var targetCompNames = ["Render 1080*1080 Target01","Render 1080*1080 Target02","Render 1080*1920 Target01","Render 1080*1920 Target02","Render 1920*1080 Target01","Render 1920*1080 Target02"]
var targetMarker = null;
var marker = null;
var foundTargetComp = false;
for (var i = 1; i <= app.project.items.length; i++) {
var item = app.project.items[i];
if (item instanceof CompItem && rawCompNames.indexOf(item.name) >= 0) {
marker = item.markerProperty.keyValue(1);
targetMarker = marker.time;
foundTargetComp = true;
}
}
if (foundTargetComp) {
for (var i = 1; i <= app.project.items.length; i++) {
var item = app.project.items[i];
if (item instanceof CompItem && targetCompNames.indexOf(item.name) >= 0) {
item.workAreaEnd = targetMarker + 4 // add EndingCard's Duration
}
}
} else {
alert("Failed to find Raw Comp");
}
}
syncCompOutPoints();I don't know where the problem is. I hope someone could help me. Thank you very much!!
