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

Function timecodeToFrames

packages/core/src/timecode.ts:22–42  ·  view source on GitHub ↗
(timecode: string, fps: number)

Source from the content-addressed store, hash-verified

20}
21
22export function timecodeToFrames(timecode: string, fps: number): number {
23 if (fps <= 0) {
24 throw new HeliosError(HeliosErrorCode.INVALID_FPS, "FPS must be greater than 0");
25 }
26
27 const match = timecode.match(/^(\d{2}):(\d{2}):(\d{2}):(\d{2})$/);
28 if (!match) {
29 throw new HeliosError(
30 HeliosErrorCode.INVALID_TIMECODE_FORMAT,
31 `Invalid timecode format: ${timecode}`,
32 "Timecode must be in HH:MM:SS:FF format"
33 );
34 }
35
36 const h = parseInt(match[1], 10);
37 const m = parseInt(match[2], 10);
38 const s = parseInt(match[3], 10);
39 const f = parseInt(match[4], 10);
40
41 return (h * 3600 + m * 60 + s) * fps + f;
42}
43
44export function framesToTimestamp(frame: number, fps: number): string {
45 if (fps <= 0) {

Callers 3

parseTimecodeFunction · 0.90
commitFunction · 0.90
timecode.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected