Skip to main content
Inspiring
August 22, 2017
Answered

Clip Marker: Different start/end time in seconds

  • August 22, 2017
  • 1 reply
  • 4139 views

Hi All,

I am adding a marker in clip using below code:

var markers = app.project.rootItem.children[0].getMarkers();

var new_marker = markers.createMarker(2.075469);

new_marker.name = "Test marker";

new_marker.comments = "Test comment";

new_marker.end = 2.075469;

Now I need to check that the marker already exists or not at "2.075469". I am using below code to compare the start and end seconds.

var markers = app.project.rootItem.children[0].getMarkers();

var start = markers.getFirstMarker().start.seconds;

var end = markers.getFirstMarker().end.seconds;

var secondsToCompare = 2.075469;
if (secondsToCompare == start && secondsToCompare == end) {

     // Marker is already exists so do nothing

}

else {

     // Add new marker

}

However value of both "start" and "end" is "2.08" which is not same as "2.075469".
Why premiere pro doesn't return exact value? Can anyone suggest how to achieve this?

Premiere Pro Version: 9.0.0
Extension Type: Panel


Thanks & Regards,
Meet Tank

This topic has been closed for replies.
Correct answer sberic

meett9325076  wrote

Hi e.d.

Yes. FPS is 25. Is there any other way to compare start and end time?

Thanks,
Meet

If you know the FPS, could you not create your own utility function that converts your "suggested" time to an FPS-locked version before doing the actual comparison? This would theoretically be a function that takes "2.075469" and returns you "2.08" in this example.

One thing to be extremely careful about is equality with floating point numbers (the ExtendScript number format should be a double-precision floating point value internally). Many numbers that are easy to type are only approximated and you can get surprising results with simple values.

Therefore, it is probably best to consider this problem at a given resolution. Many programmers use an "epsilon" value to compare floating point numbers, saying "if the difference between the test value and target value is less than the epsilon value, then they're 'equal-enough' for us!" Another way to say this is that "the two values are the same up to a resolution of X". In your case, the X could simply be 25FPS. Effectively, if you find a marker that's both:

  • greater than targetTime - (1/25), and
  • less than targetTime + (1/25)

then you could say "a marker already exists at this time."

Does that make sense? Is this not what you're trying to accomplish?

[Sorry if you were already aware of all of this! At the very least, someone else may find this information helpful! ]

1 reply

Inspiring
August 22, 2017

Hi Meet,

just guessing, but are you using 25fps footage? The marker you're

setting could be set to the nearest matching frame time by Premiere.

Inspiring
August 23, 2017

Hi e.d.

Yes. FPS is 25. Is there any other way to compare start and end time?

Thanks,
Meet

Bruce Bullis
Legend
August 23, 2017

Timecode rounding issues aside, it'd help if you could see each marker's GUID, right?