Copy link to clipboard
Copied
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
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 doub
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Timecode rounding issues aside, it'd help if you could see each marker's GUID, right?
Copy link to clipboard
Copied
Hi Bruce,
can you confirm the resolution/precision of a marker's time depends on the frame rate (or more precisely, the edit units) of the clip / sequence the marker is referring to? (In conclusion, the precision for common audio would be 1/48,000 th of a second.)
(Though a GUID is technically preferrable it might make more sense to use time reference, depending on the workflow which hasn't been described so far.)
Copy link to clipboard
Copied
That sounds easily testable.
I've ask for authoritative guidance. Internally, PPro's time precision is in ticks; 254016000000 ticks per second.
Copy link to clipboard
Copied
Thank you Bruce Bullis​. We don't get GUID after adding a marker and we don't want to store the marker's GUID for each project item so this seems not useful to us. Our goal is to prevent duplicate marker on same start and end time. Do we have any other way to accomplish this?
Thanks,
Meet
Copy link to clipboard
Copied
There's no good way to do so, today, without maintaining your own db of marker information.
Exposing marker GUIDs has been hotly requested for some time, and is near the top of our API backlog.
Copy link to clipboard
Copied
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:
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! ]
Copy link to clipboard
Copied
Thank you sberic. That is very useful.
Thanks,
Meet
Copy link to clipboard
Copied
Ok, correcting the fraction by an epsilon...
But the value with the slightly changed fraction resides inside Premiere, and not the ExtendScript.
E.g. Premiere visually sets a marker to 8secs 9frames, but displays 08:08 for its timecode value, which seems to be a bug in Premiere.
So, shouldn't Premiere calculate with epsilons?
Copy link to clipboard
Copied
Besides all that, if we correct the value by epsilon:
I can see that the "old" marker is almost exactly at the position we are checking, so I would delete the old marker and set the new one with the correct value (e.g. 8.36sec describing "00:00:08:09"), the "new" marker will be shown at "00:00:08:09" but its value shows "00:00:08:08" and the internal value seems to be 8.35999999999606secs (8 seconds and almost 9 frames).
Here is what we are doing:
And this image shows that there is something wrong inside of Premiere (or maybe I don't get it yet):
Apparently, this bug has been around for some years now.
Is there some intention to fix it, or will the panel devs keep having to cope with it?
Copy link to clipboard
Copied
Sorry, I cannot edit my posts...
The problem is, that we are reading markers from a lot of panels and background tasks.
We would have to implement an epsilon correction in a lot of places!
Copy link to clipboard
Copied
Hey it's me again 😉
Additionally, I have a slight feeling that these fraction precision deviation might also lure inside clip/sequence start/end times.
If we encountered something like that, we would have to rewrite a lot of code.
Maybe this should be somewhere inside the example code in github...
So does anyone know if this is an issue in other timecodes too?
Copy link to clipboard
Copied
One last thing:
When setting a marker "manually" from the Premiere menu, its value is correct (e.g. 08:09 => 8.36sec).
The deviation problem seems to be somewhere inside the jsx "markers.createMarker(8.36)" function...
Copy link to clipboard
Copied
The place to post this so it goes to the engineers would be their UserVoice system. Post this information over their with complete details. Every post is read and logged into their system by at least one engineer. And then all posts are collated and sent to the upper managers who determine budgets and live by metrics.
Give them metrics.
Neil