-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathISO_MakeSeamlessLoop.jsx
More file actions
87 lines (61 loc) · 2.32 KB
/
Copy pathISO_MakeSeamlessLoop.jsx
File metadata and controls
87 lines (61 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// ISO_MakeSeamlessLoop.jsx
// Artist: https://www.jasonfletcher.info/
// Code generated by ChatGPT-5.3
// Date: March 12, 2026
// Description: This After Effects script will create a seamless loop (with user-defined crossfade length) for the selected comps in the project window.
// IMPORTANT NOTE: You must precompose the main comp before executing this script.
(function () {
var proj = app.project;
if (!proj || proj.selection.length === 0) {
alert("Select one or more comps in the Project panel.");
return;
}
// Ask user for crossfade length
var input = prompt("Enter crossfade length in frames:", "120");
if (input === null) {
return; // user cancelled
}
var fadeFrames = parseInt(input, 10);
if (isNaN(fadeFrames) || fadeFrames <= 0) {
alert("Please enter a valid number of frames.");
return;
}
app.beginUndoGroup("Create Seamless Loop");
var processedCount = 0;
for (var i = 0; i < proj.selection.length; i++) {
var comp = proj.selection[i];
if (!(comp instanceof CompItem)) {
continue;
}
if (comp.numLayers < 1) {
continue;
}
var fadeDur = fadeFrames / comp.frameRate;
var baseLayer = comp.layer(1);
var originalDuration = comp.duration;
var newDuration = originalDuration - fadeDur;
// Duplicate layer (top)
var loopLayer = baseLayer.duplicate();
loopLayer.moveBefore(baseLayer);
// Bottom layer: remove first frames
baseLayer.startTime -= fadeDur;
baseLayer.inPoint = 0;
baseLayer.outPoint = newDuration;
// Top layer: first frames placed over end
loopLayer.startTime = newDuration - fadeDur;
loopLayer.inPoint = newDuration - fadeDur;
loopLayer.outPoint = newDuration;
// Crossfade (only top layer animated)
var opacity = loopLayer.property("Transform").property("Opacity");
opacity.setValueAtTime(newDuration - fadeDur, 0);
opacity.setValueAtTime(newDuration, 100);
// Adjust comp duration
comp.duration = newDuration;
processedCount++;
}
app.endUndoGroup();
alert(
"Comps processed: " + processedCount + "\n" +
"Crossfade applied: " + fadeFrames + " frames"
);
})();