Repository navigation
feat(time): add frame-grid helpers - #81
renezander030 merged 2 commits into
Conversation
Expose framesFor and quantizeToFrame through the public library entry point so callers can opt into CapCut's nearest-frame duration rounding without changing any existing command writes.\n\nCover the measured issue rows, sub-frame behavior, fractional rates, and the documented 30 fps fallback.\n\nCloses renezander030#76.\n\nAI-assisted: OpenAI Codex helped implement and validate this change; the contributor reviewed the final diff.
|
Thanks Floze — this landed exactly where the issue asked: helpers in One thing I'd like pinned down before merge. The third acceptance criterion asks that sub-frame durations survive rather than collapsing to zero. So a caller who quantises a short segment before writing turns it into a zero-length one. The 33 ms test passes over this because 33 ms happens to sit just under a full frame, not because the floor is handled. Two ways to go, and I don't mind which:
I lean towards (1), since the helper exists so callers can quantise safely, and returning 0 for a real segment is the one result that is never useful. Either way, a test that names the case. Two smaller notes, neither blocking:
|
Floor positive sub-half-frame durations at one frame while preserving zero and signed negative rounding. Document and test the boundary explicitly. AI-assisted: OpenAI Codex helped implement and validate this maintainer-requested follow-up; the contributor reviewed the final diff.
|
Implemented your preferred option (1) in Local follow-up validation is green: 665 tests (654 passed, 11 skipped), Biome on 125 files, package dry-run with |
renezander030
left a comment
There was a problem hiding this comment.
Exactly what I asked for, and faster than I expected. The floor is in the right place — inside a single private framesAtRate so both exports share it — and the regression test names the case rather than relying on 33 ms happening to sit just under a frame. Documenting the negative-duration behaviour instead of quietly clamping it was the right call too.
Verified locally against the new head: all five #69 rows still land on 83 / 94 / 10 / 26 / 26, 1 ms and 16 ms now floor to one frame at 33333 µs, zero stays zero, and 29.97 / 23.976 stay finite. Full CI green across Node 18/20/22, lint, and platform smoke on all three OSes.
Merging. Thank you for the contribution — a first PR that arrives scoped to the issue, tested the way the repo asks, and turned around on review this cleanly is genuinely rare. Please do pick up another one.
Summary
framesFor(us, fps)andquantizeToFrame(us, fps)from the public library entry pointCloses #76.
Validation
0 !== 1npm test— 665 tests: 654 passed, 11 skipped, 0 failednpm run lint— 125 files checked, no warnings or errorsnpm pack --dry-run— package includesdist/time.d.tsgit diff --checkAI disclosure
OpenAI Codex assisted with implementation and validation. I reviewed the final diff and test results.