Copy link to clipboard
Copied
If anyone would be so kind as to write me a script, I would be forever grateful.
I'd like the commands in this order please.
1. Skip ahead 44 frames from current position
2. Cut the layer
3. Skip ahead 45 frames from current position
4. Cut the layer
5. Move down one layer and delete (optional step)
6. Go backwards 45 frames from current position
7. Move the beginning of topmost layer to current position
8. Repeat
Thanks in advance to anyone who can help!
Copy link to clipboard
Copied
If I understand your description, you want to trim selected layers to a length of 45 frames starting from where the timeline cursor is positioned, then slide the trimmed layers to start at the timeline cursor. Like so...
This should do it, as long as your layers are not reversed (stretched in the negative direction).
app.beginUndoGroup("Trim and shift layers");
var proj = app.project;
var curComp = proj.activeItem;
if(curComp instanceof CompItem){
var selLayers = curComp.selectedLayers;
var selLayersLen = selLayers.length;
var curCompTime = curComp.time;
var frameDur = curComp.frameDuration;
var offset = (frameDur * 45);
var curLayer;
for(var i=0; i<selLayersLen; i++){
curLayer = selLayers;
curLayer.inPoint = (curCompTime + (offset-frameDur));
curLayer.outPoint = (curLayer.inPoint + offset);
curLayer.startTime -= (offset-frameDur);
}
}else{
alert("Please select a composition.");
}
app.endUndoGroup();
Copy link to clipboard
Copied
I want to trim repetitive repeats of a video.
What is going on is the video plays for 43 frames, then for 44 frames that same portion I just watched is repeat from a different camera angle. I want to trim camera angle 2 out of the video. If that makes any sense.
Copy link to clipboard
Copied
I want to trim repetitive repeats of a video.
What is going on is the video plays for 43 frames, then for 44 frames that same portion I just watched is repeat from a different camera angle. I want to trim camera angle 2 out of the video. If that makes any sense.
Ok, I believe then, the code I posted should do it then. You may need to adjust the offset variable to dial it in. I haven't tried Dan's solution yet, but that may work as well.
Copy link to clipboard
Copied
I'm guessing it might look like this:
function doIt(numTimes){
var skipFrames1 = 44;
var skipFrames2 = 45;
var myComp = app.project.activeItem;
if ((myComp == null) || ! (myComp instanceof CompItem)){
alert("No comp selected.");
return;
}
if(myComp.selectedLayers.length == 0){
alert("No layer selected.");
return;
}
var oldLayer = myComp.selectedLayers[0];
var curTime = myComp.time;
var oldTime = curTime;
var newLayer;
for (var i = 0; i < numTimes; i++){
curTime += skipFrames1*myComp.frameDuration;
newLayer = oldLayer.duplicate();
oldLayer.outPoint = oldTime;
newLayer.inPoint = curTime + skipFrames2*myComp.frameDuration;
newLayer.startTime -= (skipFrames1 + skipFrames2)*myComp.frameDuration;
oldLayer = newLayer;
oldTime = curTime;
}
}
app.beginUndoGroup("Split Layer");
doIt(4); // do it 4 times
app.endUndoGroup();