Converting Time to Timecode and Percent: Check my math?
-
So I'm making User Actors based on Media Percent to Time and Media Time to Percent that also take into consideration the speed at which the media is played, and also allow you to convert things to and from timecode.
I keep second-guessing myself on the math, so I wanted to put what I have out here and see if anyone can poke holes in it for me.
Conversion: Time --> Percent or Timecode = you must multiply the percent or timecode value by the absolute value of the speed
T-->P/TC Examples: (Assuming a 10 second video that's 30 fps)
- Speed 1, Input: 1 sec --> Output: 10% / 00:00:01:00/30
- T--> P: 1 sec = 10% of 10 seconds --> 10% x |1| = 10%
- T--> TC: 1 sec = 00:00:01:00/30 --> 00:00:01:00/30 x |1| = 00:00:01:00/30
- Speed -1, Input: 1 sec --> Output: 10% / 00:00:01:00/30
- T--> P: 1 sec = 10% of 10 seconds --> 10% x |-1| = 10%
- T--> TC: 1 sec = 00:00:01:00/30 --> 00:00:01:00/30 x |-1| = 00:00:01:00/30
- Speed 2, Input: 0.5 sec --> Output: 10% / 00:00:01:00/30
- T--> P: 0.5 sec = 5% of 10 seconds --> 5% x |2| = 10%
- T--> TC: 0.5 sec = 00:00:00:15/30 --> 00:00:00:15/30 x |2| = 00:00:01:00/30
- Speed 2, Input: 1 sec --> Output: 20% / 00:00:02:00/30
- T--> P: 1 sec = 10% of 10 seconds --> 10% x |2| = 20%
- T--> TC: 1 sec = 00:00:01:00/30 --> 00:00:01:00/30 x |2| = 00:00:02:00/30
- Speed -2, Input: 1 sec --> Output: 20% / 00:00:02:00/30
- T--> P: 1 sec = 10% of 10 seconds --> 10% x |-2| = 20%
- T--> TC: 1 sec = 00:00:01:00/30 --> 00:00:01:00/30 x |-2| = 00:00:02:00/30
- Speed 0.5, Input: 1 sec --> Output: 5% / 00:00:00:15/30
- T--> P: 1 sec = 10% of 10 seconds --> 10% x |0.5| = 5%
- T--> TC: 1 sec = 00:00:01:00/30 --> 00:00:01:00/30 x |0.5| = 00:00:00:15/30
- Speed -0.5, Input: 1 sec --> Output: 5% / 00:00:00:15/30
- T--> P: 1 sec = 10% of 10 seconds --> 10% x |-0.5| = 5%
- T--> TC: 1 sec = 00:00:01:00/30 --> 00:00:01:00/30 x |-0.5| = 00:00:00:15/30
- Speed 1, Input: 0.5 sec --> Output: 5% / 00:00:00:15/30
- T--> P: 0.5 sec = 5% of 10 seconds --> 5% x |1| = 5%
- T--> TC: 0.5 sec = 00:00:00:15/30 --> 00:00:00:15/30 x |1| = 00:00:00:15/30
- Speed 0.5, Input: 0.5 sec --> Output: 2.5% / 00:00:00:08/30
- T--> P: 0.5 sec = 5% of 10 seconds --> 5% x |0.5| = 2.5%
- T--> TC: 0.5 sec = 00:00:00:15/30 --> 00:00:00:15/30 x |0.5| = 00:00:00:08/30
Conversion:
Percent --> Time = ((Percentage value x 0.01) x (Total Time Duration)) / (|Speed|) You must divide the time by the absolute value of the speed.
Percent --> Timecode = (Percentage value X 0.01) x (Total Timecode Duration). You don't need to involve speed at all.P-->T/TC Examples: (Assuming a 10 second video that's 30 fps)
- Speed 1, Input: 10% --> Output: 1 sec/ 00:00:01:00/30
- P-->T: 10% of 10 seconds = 1 sec --> 1 sec x |1| = 1 sec
- P-->TC: 00:00:10:00/30 x 0.1 = 00:00:01:00/30
- Speed -1, Input: 10% --> Output: 1 sec/ 00:00:01:00/30
- P-->T: 10% of 10 seconds = 1 sec --> 1 sec x |-1| = 1 sec
- P-->TC: 00:00:10:00/30 x 0.1 = 00:00:01:00/30
- Speed 2, Input: 5% --> Output: 0.25 seconds / 00:00:00:15/30
- P-->T: 5% of 10 seconds = 0.5 sec --> (0.5 sec)/(|2|) = 0.25 secs
- P-->TC: 00:00:10:00/30 x 0.05 = 00:00:00:15/30
- Speed 2, Input: 20% --> Output: 1 sec / 00:00:02:00/30
- P-->T: 20% of 10 seconds = 2 seconds --> (2 seconds)/(|2|) = 1 sec
- P-->TC: 00:00:10:00/30 x 0.2 = 00:00:02:00/30
- Speed -2, Input: 20% --> Output: 1 sec / 00:00:02:00/30
- P-->T: 20% of 10 seconds = 2 seconds --> (2 seconds)/(|-2|) = 1 sec
- P-->TC: 00:00:10:00/30 x 0.2 = 00:00:02:00/30
- Speed 0.5, Input: 5% --> Output: 1 sec / 00:00:00:15/30
- P-->T: 5% of 10 seconds = 0.5 sec --> (0.5 sec)/(|0.5|) = 1 sec
- P-->TC: 00:00:10:00/30 x 0.05 = 00:00:00:15/30
- Speed -0.5, Input: 5% --> Output: 1 secs / 00:00:00:15/30
- P-->T: 5% of 10 seconds = 0.5 sec --> (0.5 sec)/(|-0.5|) = 1 sec
- P-->TC: 00:00:10:00/30 x 0.05 = 00:00:00:15/30
- Speed 1, Input: 5% --> Output: 0.5 secs / 00:00:00:15/30
- P-->T: 5% of 10 seconds = 0.5 sec --> (0.5 sec)/(|1|) = 0.5 sec
- P-->TC: 00:00:10:00/30 x 0.05 = 00:00:00:15/30
- Speed 0.5, Input: 2.5% --> Output: 0.5 sec / 00:00:00:15/30
- P-->T: 2.5% of 10 seconds = 0.25 sec --> (0.25 sec)/(|0.5|) = 0.5 sec
- P-->TC: 00:00:10:00/30 x 0.025 = 00:00:00:8/30
If I'm not mistaken, then the math and examples for converting Timecode to Time should be the same, but to convert Timecode to Percentage you'd just divide to total timecode duration by the given timecode value in order to get the percentage value (no speed involved).
Did I do the math correctly?
- Speed 1, Input: 1 sec --> Output: 10% / 00:00:01:00/30
-
Take a look at these User Actors: https://troikatronix.com/add-o...
I think some of what you are looking for is covered there. -
@dusx said:
I think some of what you are looking for is covered there.
Some, yes, but the tricky thing is accounting for speed. I think I've got it figured out at this point though (unless someone tells me I'm wrong).
-
@woland said:
I think I've got it figured out at this point though (unless someone tells me I'm wrong).
It gives me a headache...
Cheers,
Hugh
-
@citizenjoe said:
It gives me a headache
Me too. After I finish the User Actor, I never want to have to do this math again.