(timecode: string, fps: number)
| 20 | } |
| 21 | |
| 22 | export 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 | |
| 44 | export function framesToTimestamp(frame: number, fps: number): string { |
| 45 | if (fps <= 0) { |
no outgoing calls
no test coverage detected