First time caller, short time listener...
So I am delving into making some scripts for my day job and running into problems. Basically, daily I layoff vfx/elements that come to me usually as file sequences to HD/23.98 (D5, HDCam SR, HDCAM). Now, the good companies actually inclusde slates. But that's probably half of the shows we work with...
The other thing is that we like to lay things off so that each shot lands on an A-frame (for down conversions). So my initial thoughts were to make (steal) a script that added a 1 sec slate and made the duration round up to an even second.
For the time being, as I'm new to this (haven't scripted in 4+ years). I am using one of Paul's scripts as basis for the duration and Lloyd's for the slate.
Well all seemed ok with the duration UNTIL I ran into a duration of over 4000 frames. It seems there is a math problem, because if I force the rame rate to 24 solid, then all is well but since it needs to be 23.98 it doesn't work. So now I come to you all for help...
- Erik
Code: Select all
// Original code by Paul Tuersley
// This is for 23.98 (maybe 24) Projects only.
//
// This script will take a 23.98 comp and will create a new comp with 1 sec
// added to the head, as well as X+24 frames to the end to make a quicktime
// file for laying off to tape - ie. 24fps VFX reel.
//
// Purpose is so that each shot starts on an A frame for downconverts. Just drop
// footage in a FCP timeline and go...
{
// create an array of selected comps
var selectedComps = new Array();
for (var i = 1; i <= app.project.items.length; ++i) {
if (app.project.items[i] instanceof CompItem && app.project.items[i].selected) {
selectedComps[selectedComps.length] = app.project.items[i];
}
}
// for each of the selected comps
for (var i = 0; i < selectedComps.length; ++i) {
// create new comp, make it one frame longer and add S to it's name
currentComp = selectedComps[i];
slateCompName = "_111_" + currentComp.name
var compBG = [0/255,0/255,0/255] // Set background color to black
// adds 1 frame to head
// slateCompDuration = currentComp.duration + (currentComp.frameDuration * 0.99);
// This is for 29.97fps
// slateCompDuration = Math.round(currentComp.duration) + (2 * 0.99);
// slateCompDuration = Math.round(currentComp.duration) + (1 * 0.99);
// slateCompDuration = Math.round(currentComp.duration) + 1 + (currentComp.frameDuration * 0.99);
// slateCompDuration = Math.round(currentComp.duration) + 1 + (currentComp.duration * 0.99);
// slateCompDuration = Math.round(currentComp.duration) + 1 + (currentComp.frameDuration * 1.04170142527805);
// slateCompDuration = Math.round(currentComp.duration) + 1.04170142527805;
// slateCompDuration = Math.round(currentComp.duration);
alert("currentComp is " + currentComp.name);
alert("currentComp.frameRate is " + currentComp.frameRate);
alert("currentComp.duration is " + currentComp.duration);
// eFindDuration = currentComp.duration/24;
// eMathDuration = Math.ceil(eFindDuration);
eNewDuration = Math.ceil(currentComp.duration) + 1;
alert("eNewDuration is " + eNewDuration);
// eFps = Math.round((1.001/currentComp.frameDuration));
// alert("eFps is " + eFps);
// alert("eFindDuration is " + eFindDuration);
// alert("eMathDuration is " + eMathDuration);
slateCompDuration = (eNewDuration) + .005;
alert("slateCompDuration is " + slateCompDuration);
// slateComp = app.project.items.addComp(slateCompName, currentComp.width, currentComp.height, currentComp.pixelAspect, slateCompDuration, currentComp.frameRate);
// Forcing new comp frame rate to 24 solid
slateComp = app.project.items.addComp(slateCompName, currentComp.width, currentComp.height, currentComp.pixelAspect, slateCompDuration, 24);
// alert("slateComp.frameRate is " + slateComp.frameRate);
// slateComp.frameRate = 23.98;
// alert("slateComp.frameRate is " + slateComp.frameRate);
// add orignal comp
precompLayer = slateComp.layers.add(currentComp);
slateComp.bgColor = compBG;
// FYI - 1 frame @ 24fps = 0.04170142527805
// precompLayer.startTime = 1
}
}