• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Can someone help me write a script?

Community Beginner ,
Jul 20, 2015 Jul 20, 2015

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!

TOPICS
Scripting

Views

393

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 20, 2015 Jul 20, 2015

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...

TrimLayers.jpg

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();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 20, 2015 Jul 20, 2015

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 22, 2015 Jul 22, 2015

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 20, 2015 Jul 20, 2015

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(); 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines