FORUMS: list search recent posts

Creating a script to split a footage into multiple comps?

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Alexis Coco
Creating a script to split a footage into multiple comps?
on Apr 27, 2020 at 4:20:02 pm
Last Edited By Alexis Coco on Apr 27, 2020 at 4:40:27 pm

Hi there,

I'm working on a script that allows me to cut a long footage into several compositions.

The idea is that on a 5 minutes footage for example, I get 30 seconds comps with a 10 seconds delay on my footage between each comps. Finally, I'll have 27 comps of 30 seconds with my footage in them, which starts 10 seconds later each time.

Unfortunately, I can't figure out how to create a function that allows me to cut my items at a given interval and then loop it.

Do you have any ideas?
Thank you very much!

Return to posts index

Walter Soyka
Re: Creating a script to split a footage into multiple comps?
on Apr 27, 2020 at 10:53:11 pm


I'm here to teach, so please ask questions for anything you don't understand.

// we might make a lot of comps, so let's make sure we can un-make them easily!
app.beginUndoGroup("Make some comps!");

// set originalSource to refer to the footage item you want to offset across your comps
var originalSource = app.project.item(1);

// how many seconds should each comp be?
var compDuration = 30;

// how much time should we offset in each new comp we create?
var timeOffset = 10;

// keep creating comps until we've offset the entire duration
for (var i = 0; i < originalSource.duration / timeOffset; i++) {
// make the new comp with the same properties as the originalSource, but at our custom duration
var newComp = app.project.items.addComp("Comp " + (i+1), originalSource.width, originalSource.height, originalSource.pixelAspect, compDuration, originalSource.frameRate);

// add the originalSource as a new layer in that new comp
var newLayer = newComp.layers.add(originalSource);

// pull the start time back according to the total offset for this specific comp, then trim the inPoint back to zero for cleanliness's sake
newLayer.startTime = -timeOffset* i;
newLayer.inPoint = 0;

// delete the comp if the duration of the trimmed footage is less than the duration -- no blank spaces!
if (newLayer.outPoint < newComp.duration) newComp.remove();


Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]

Return to posts index

Alexis Coco
Re: Creating a script to split a footage into multiple comps?
on Apr 28, 2020 at 8:33:51 am

Hi Walter,

Thanks a lot for your amazingly fast answer 😃

That's exactly what i was looking for.
I was stuck with this:

newLayer.startTime = -timeOffset* i;
newLayer.inPoint = 0;

And that one is the cherry on the cake:
if (newLayer.outPoint < newComp.duration) newComp.remove();

Thanks a lot for the help, your code is very clear 😉
So helpful!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 All Rights Reserved