MCPcopy Create free account
hub / github.com/BintzGavin/helios / framesToTimecode

Function framesToTimecode

packages/core/src/timecode.ts:3–20  ·  view source on GitHub ↗
(frame: number, fps: number)

Source from the content-addressed store, hash-verified

1import { HeliosError, HeliosErrorCode } from './errors.js';
2
3export function framesToTimecode(frame: number, fps: number): string {
4 if (fps <= 0) {
5 throw new HeliosError(HeliosErrorCode.INVALID_FPS, "FPS must be greater than 0");
6 }
7
8 // Ensure frame is non-negative and integer
9 const safeFrame = Math.max(0, Math.floor(frame));
10
11 const totalSeconds = Math.floor(safeFrame / fps);
12 const f = safeFrame % fps;
13 const s = totalSeconds % 60;
14 const m = Math.floor(totalSeconds / 60) % 60;
15 const h = Math.floor(totalSeconds / 3600);
16
17 const pad = (n: number) => n.toString().padStart(2, '0');
18
19 return `${pad(h)}:${pad(m)}:${pad(s)}:${pad(f)}`;
20}
21
22export function timecodeToFrames(timecode: string, fps: number): number {
23 if (fps <= 0) {

Callers 7

TimelineFunction · 0.90
formatTimeFunction · 0.90
TimecodeInputFunction · 0.90
commitChangeFunction · 0.90
handleKeyDownFunction · 0.90
TimecodeDisplayFunction · 0.90
timecode.test.tsFile · 0.85

Calls 1

padFunction · 0.70

Tested by

no test coverage detected