Expression Copied to Clipboard! πŸ—‚
← Back to Expressions

Auto Fade In & Out by Marker Duration - After Effects Expression

Fade a layer in and out using markers to set the duration

Auto Fade In & Out by Marker Duration

fadeFrames = 6; m = 0; t=time;
if(marker.numKeys > 0) {
m = marker.nearestKey(time).index;
tag = marker.key(m).comment;
if(tag == 'Highlight'){
tMin = marker.key(m).time;
tMax = tMin + marker.key(m).duration;

if(t < tMin){
linear(time, tMin - framesToTime(fadeFrames), tMin, 0, value);
} else {
linear(time, tMax - framesToTime(fadeFrames), tMax, value, 0);
}
} else {
value;
}
} else {value}

‍

Copied to Clipboard!
fadeFrames = 6; m = 0; t=time;
if(marker.numKeys > 0) { m = marker.nearestKey(time).index; tag = marker.key(m).comment; if(tag == 'Highlight'){ tMin = marker.key(m).time; tMax = tMin + marker.key(m).duration; if(t < tMin){ linear(time, tMin - framesToTime(fadeFrames), tMin, 0, value); } else { linear(time, tMax - framesToTime(fadeFrames), tMax, value, 0); } } else { value; }
} else {value}

More expressions you might like...

Credit