The expression attached below will give you the time of the 2nd marker ahead of your playhead.
var action = thisComp.layer(1);
//get the time of the closest key.
var theKey = action.marker.nearestKey(time);
//determine if nearest key is before or after
//the current time
var lookAhead;
if(theKey.time <= time){
//key is before, get 2 markers past this one.
lookAhead = Math.min(theKey.index + 2, action.marker.numKeys);
} else {
//next key is ahead, get one marker past this one.
lookAhead = Math.min(theKey.index + 1, action.marker.numKeys);
}
//get time of 2 keys ahead.
var twoKeysAheadTime = action.marker.key(lookAhead).time;
twoKeysAheadTime;
However, this will not be useful to you in constructing a fade as the way the linear() function works cannot create values in the future. Take this as an example:
linear(time, nextMarker.time, twoMarkersahead.time, 0, 100);
This expression won’t do anything as your playhead (i.e. the value of time) can, by definition, never be between the next marker and 2 markers ahead, it will either be 1) before all markers, 2) between the previous and next marker, or 3) past all markers.
So, let’s discuss other ways of doing this. If you know that you want your fade to happen between the last 2 markers on your layer, you could do something like:
linear(time, marker.key(marker.numKeys-1).time, marker.key(marker.numKeys).time, 0, 100);
You can change the numbers to move back to the third-to-last and second-to-last keyframes as such:
linear(time, marker.key(marker.numKeys – 2).time, marker.key(marker.numKeys – 1).time, 0, 100);
Hopefully that points you in the right direction. If you have more info about what, exactly, it is you’re trying to do I may be able to give you some case-specific advice.
Good luck!
David Conklin
Motion Designer