Skip to main content
TheYates
Known Participant
August 5, 2022
Answered

Subtitle To Disappear After Marker End.

  • August 5, 2022
  • 1 reply
  • 256 views

Hello, I am working with this expression for subtitles but the subtitle stays on even until the next marker. I want subtitle to disappear when there's a gap between markers.

Any help?

Here's the expression I am using;

m = thisComp.layer(1).marker;
n = 0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time){
n--;
}
}
if (n == 0){
""
}else{
m.key(n).comment;
}

 

 

This topic has been closed for replies.
Correct answer Dan Ebberts

Try it this way:

m = thisComp.layer(1).marker;
n = 0;
val = "";
if (m.numKeys > 0){
  n = m.nearestKey(time).index;
  if (m.key(n).time > time) n--;
}
if (n > 0){
  t = time - m.key(n).time;
  if (t < m.key(n).duration){
    val = m.key(n).comment;
  }
}
val

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
August 5, 2022

Try it this way:

m = thisComp.layer(1).marker;
n = 0;
val = "";
if (m.numKeys > 0){
  n = m.nearestKey(time).index;
  if (m.key(n).time > time) n--;
}
if (n > 0){
  t = time - m.key(n).time;
  if (t < m.key(n).duration){
    val = m.key(n).comment;
  }
}
val
TheYates
TheYatesAuthor
Known Participant
August 7, 2022

Thank you very much, Dan Ebberts.