You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While building a film and scoring tool that depends on this library, I ran into some odd precision issues on values far smaller than expected based on the claims of the library.
Initially I believed it was after repeated conversion back and forth between Timecode and time.Duration, but in fact the behaviour just occurs above certain arbitrary values per edit rate.
For a 24fps edit rate, the timestamp begins to drift by whole frames during the 375th hour — a lot less than 9 years.
This example shows a timecode gaining an extra frame immediately on creation —
package main
import"fmt"import"time"import lib "github.com/trimmer-io/go-timecode/timecode"funcmain() {
constDURATION=time.Hour*375tc:=lib.New(DURATION, lib.Rate24)
fmt.Println(tc)
}
375:00:00:01
The problem occurs far earlier at higher edit rates, such as —
60fps — 58th hour
120fps — 28th hour
In theory, this shouldn't come up in most use-cases, but the precision claim is wildly overstated and anyone who might be using the library under the assumption of high-precision without questioning it may be surprised.
I was going to build a better example using a zero tc and adding 32,000,000 frames to it to show it coughing back up 32,000,001 from tc.Frame() but, while doing that I also discovered that AddFrames with a frame number greater than the existing frame count of the Timecode just clamps it to zero.
The negative result gate is implemented backwards; positive values greater than the base tc value are zero'd, and negative values are freely allowed to wrap around.
While building a film and scoring tool that depends on this library, I ran into some odd precision issues on values far smaller than expected based on the claims of the library.
Initially I believed it was after repeated conversion back and forth between
Timecode
andtime.Duration
, but in fact the behaviour just occurs above certain arbitrary values per edit rate.For a 24fps edit rate, the timestamp begins to drift by whole frames during the 375th hour — a lot less than 9 years.
This example shows a timecode gaining an extra frame immediately on creation —
The problem occurs far earlier at higher edit rates, such as —
In theory, this shouldn't come up in most use-cases, but the precision claim is wildly overstated and anyone who might be using the library under the assumption of high-precision without questioning it may be surprised.
I was going to build a better example using a zero tc and adding 32,000,000 frames to it to show it coughing back up 32,000,001 from
tc.Frame()
but, while doing that I also discovered thatAddFrames
with a frame number greater than the existing frame count of theTimecode
just clamps it to zero.The negative result gate is implemented backwards; positive values greater than the base tc value are zero'd, and negative values are freely allowed to wrap around.
The text was updated successfully, but these errors were encountered: