Return the time difference between two markers

Hi everyone,

I am trying to find the time difference between multiple markers and return that difference as a value. For example, find marker one, find marker two, determine difference, return value. Have an action happen if longer than 1 second. Then the same with m2 & m3…m3 & m4. Does anyone have any ideas? I am still very confused about collections, which I think is the key here, even after looking into the reverse layer names & split layers at markers jsons that have been shared on here. Or maybe this isn’t a simple few lines? The total number of markers can vary.

Even small guidance is appreciated; I am learning best by building myself rather than copy & paste.

Thanks.

Hi @pennytron, this automation is not very complex, to compare every marker with the next marker you have to use a combination of 2 loops, the main loop will loop through all the markers (without the last marker). inside the loop you will have to create a number variable that will be the index of the next marker, then you will loop again on all of the markers and search for the marker with the index of the next marker, after you find the next marker you can create another variable to calculate the difference between the times, then ask if this variable greater than 1, inside add the functionality you want.
the example - Markers Time Diff.json (8.9 KB)
Alon.

Thank you so much! I can see where my logic went wrong. I never set a variable set to the current comp (the variable in your json called “comp”), I just had a number variable that I would set later on; and I didn’t nest the loops, so I pretty much had the “current marker loop” and “next marker loop” as separate loops which of course meant I kept returning a string of values that I then couldn’t calculate with.

I made a copy that reads layer markers in case this helps anyone in the future.

Markers Time Diff on layers.json (9.5 KB)