`Timecode.to_realtime(as_float=False)` returns incorrect value for "00:00:00:00" at low frame rates.
Simply put, using the to_realtime method for low and higher frame rates on a "00:00:00:00" timecode produces the following inconsistent results:
>>> Timecode(24, "00:00:00:00").to_realtime(as_float=False)
'00:00:00.042'
>>> Timecode(48000, "00:00:00:00").to_realtime(as_float=False)
'00:00:00.000'
which I believe is incorrect. My hunch is the addition of 42ms is due to the Timecode object always requiring a frame count of 1; 1000/24 = 41.66
Also, just wanted to say thanks for maintaining this library, it's super lightweight and fits our usecase perfectly 😄
@lucien-flwls thank you. I think we loose quite a bit of resolution for very high frame rates and it cannot represent it properly. Otherwise yes "00:00:00:00" is the timecode of the first frame, so there is 1 frame, you're correct.
Hi, A timecode running at 48000 fps displays the very first frame at $48000^{-1} = 2.08\overline{3}\cdot{}10^{-5} = 0.0208\overline{3}\ ms$. This value can only be truncated towards zero when exporting to the (rather) standardized timestamp format with millisecond precision.
I believe you are better off producing your own precise timestamp string with the result of as_float=True. Changing the return format of as_float=False to include microseconds, in a variable manner will displease most users. At best a parameter could be appended to specify the precision, or a datetime string format to fill. But that may be a lot of complexity for very little gain.
As to the correctness at the standard framerate of 24 fps: 00:00:00:00 is the timecode of the first frame. This frame takes 41.6 ms to be drawn and displayed on your screen. Hence the real time is not $0\ ms$ but $41.6\ ms$.
Here's what SMPTE-12M says:
5.1.1 Definition of real time In a system operating at a frame rate of 30 frames per second, exactly one second of real time elapses during the duration of 30 frames. In a system operating at a frame rate of 60 frames per second, exactly one second of real time elapses during the duration of 60 frames.
We can verify this:
assert 30 == Timecode(30, "00:00:00:29").frames ## There are 30 frames
assert 1.0 == Timecode(30, "00:00:00:29").to_realtime(True) ## Exactly 1 s elapsed in real time.