Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Trying to adjust inPoint of a layer

  • Trying to adjust inPoint of a layer

    Posted by Rob Packer on September 18, 2024 at 4:20 am

    I am editing some old VHS videos that were put onto DVD. There are sections that need to be removed. I have created a simple dialog with buttons to simplify editing. One button successfully splits a layer then reverses the order so that the extra layer is below the original. I then move forward to the point where the extra layer needs to split and the section deleted. eg. at 10 seconds the footage becomes static, I split and reorder it there. At 15 seconds the static ends.

    How do I split the layer, delete the 10-15 second section and move the next section of the footage back to the outPoint of the layer above?

    What I have so far is this:

    splitAdjust.onClick = function() {

    var myComp = app.project.activeItem;

    var selectedLayer = myComp.selectedLayers;

    var currLayerIndex = selectedLayer[0].index;

    var delLayerIndex = currLayerIndex + 1;

    var prevLayer = myComp.layer(currLayerIndex – 1);

    var fadePoint = prevLayer.outPoint;

    if (selectedLayer.length > 0){

    app.executeCommand(app.findMenuCommandId(“Split Layer”));

    app.project.activeItem.layer(delLayerIndex).remove();

    app.project.activeItem.time = fadePoint;

    app.project.activeItem.layer(currLayerIndex);

    myComp.layer(currLayerIndex).inPoint = fadePoint;

    }else{

    alert (“No layers selected.”);

    }

    }

    Hopefully someone can help!

    Brie Clayton
    replied 3 weeks, 4 days ago
    3 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    September 18, 2024 at 1:07 pm

    I think I would try not to use any menu commands, if possible. So I’d try a workflow like this: you drop a marker layer at one end of the area you want to cut out and move the CTI (current time indicator) to the other end, and run a function like this (which you could attach to your button):

    function splitAdjust(){
    var myComp = app.project.activeItem;
    if (!(myComp && (myComp instanceof CompItem))){
    alert ("No comp selected.");
    return;
    }
    if (! (myComp.selectedLayers.length > 0)){
    alert("No layer selected.");
    return;
    }
    var myLayer = myComp.selectedLayers[0];
    if (! (myLayer.property("Marker").numKeys > 0)){
    alert("Selected layer has no marker.");
    return;
    }
    var compTime = myComp.time;
    var markerTime = myLayer.property("Marker").keyTime(1);
    myDup = myLayer.duplicate();
    myDup.moveAfter(myLayer);
    if (markerTime < compTime){
    var t1 = markerTime;
    var t2 = compTime;
    }else{
    var t1 = compTime;
    var t2 = markerTime;
    }
    myLayer.outPoint = t1;
    myDup.inPoint = t2;
    myDup.startTime -= t2-t1;
    myLayer.property("Marker").removeKey(1);
    myDup.property("Marker").removeKey(1);
    }
    splitAdjust();
  • Rob Packer

    September 18, 2024 at 11:32 pm

    Thank you @danebberts! That works perfectly.

    I have included an Add marker button on my dialog.

    Can you tell me what the command is to move to the next/previous marker is?

    Rob

  • Dan Ebberts

    September 19, 2024 at 12:16 am

    You generally access a marker by its key index, like this:

    property("Marker").key(1)

    or by time, like this:

    property("Marker").nearestKeyIndex(myComp.time)
  • Brie Clayton

    September 19, 2024 at 12:55 am

    Thank you for solving this, Dan!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy