3

I have been at this for a few days and while I have made progress I am stuck on the last bit, getting timecode to display as HH:MM:SS:MS rather than HH:MM:SS:FF. To do this I need a formula for the milliseconds part

I know this is will be complicated for Drop-Frame Timecodes so I have ruled them out. I am only concerned with NDF Timecodes.

The formula I have for finding a NDF Timecode, for example a video of 30 frames with a 12 FPS:

  1. To get the hours, 30 / (12* 3600), 3600 is the number of seconds in a hour
  2. To get the minutes, 30 / (12 * 60) - (0 * 60), 0 is the sum from step 1
  3. To get the seconds, (30 / 12) - ( (0 * 3600) - (0 * 60)
  4. To get the frames, 30 % 12 (Modulas)

The Timecode would be 00:00:02:06, as shown at Frames to Timecode Calculator.

I would like to make a slight tweak at step 4, to instead get the milliseconds needed for format HH:MM:SS:MMM. I have tried to unsuccessfully solve it on my own, I searched around and turned up with nothing too.

I am not a math wizard by any chance, not even a half rate one. I would really like to learn how to do this though. Any help would be greatly appreciated!

1 Answer 1

1

Frames are fractions of a second, thus:

frameduration = 1 / framerate
framecomponent = totalframes % framerate
millisecondscomponent = framecomponent * frameduration * 1000
// finally
millisecondscomponent = ((totalframes % framerate) * 1000 ) / framerate

In your example:

millisecondscomponent = ((30 % 12) * 1000 ) / 12 = 500 ms
1
  • Thank you for this, I understand it much better now and can do it on my own. Dec 25, 2023 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.