{"record":{"id":"404c75c8cc3d7c73","repo":"remotion-dev/remotion","slug":"invalid-timestamp-time","errorCode":null,"errorMessage":"Invalid timestamp:${time}","messagePattern":"Invalid timestamp:(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/captions/src/parse-srt.ts","lineNumber":6,"sourceCode":"import type {Caption} from './caption';\n\nfunction toSeconds(time: string) {\n\tconst [first, second, third] = time.split(':');\n\tif (!first) {\n\t\tthrow new Error(`Invalid timestamp:${time}`);\n\t}\n\n\tif (!second) {\n\t\tthrow new Error(`Invalid timestamp:${time}`);\n\t}\n\n\tif (!third) {\n\t\tthrow new Error(`Invalid timestamp:${time}`);\n\t}\n\n\tconst [seconds, millis] = third.split(',');\n\tif (!seconds) {\n\t\tthrow new Error(`Invalid timestamp:${time}`);\n\t}\n\n\tif (!millis) {\n\t\tthrow new Error(`Invalid timestamp:${time}`);\n\t}","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/captions/src/parse-srt.ts#L1-L24","documentation":"`toSeconds` splits an SRT timestamp on ':' expecting exactly three parts (hours:minutes:seconds). If the first segment (`hours`) is empty/undefined, the timestamp is malformed and the error is thrown with the raw input. This is the first of five sequential validations in `parseSrt`'s timestamp parser.","triggerScenarios":"An SRT timestamp string missing the hours component or starting with ':' (e.g. ':00:00,000'); a timestamp with fewer than two colons; an empty timestamp string passed to `toSeconds`.","commonSituations":"Hand-edited or machine-generated SRT with non-standard timestamps; VTT timestamps (which use '.' for milliseconds and sometimes omit hours) fed to the SRT parser; locale-specific time formatting; truncated copy-paste.","solutions":["Ensure timestamps follow SRT format HH:MM:SS,mmm (hours required).","Pre-validate timestamps with a regex like /^\\d+:\\d{2}:\\d{2},\\d{3}$/.","If using VTT, convert to SRT format or use a VTT parser.","Normalize empty segments before parsing."],"exampleFix":"// before\n// SRT line: \":00:05,000 --> :00:07,000\"\nparseSrt({input: srtWithBadTimestamps});\n\n// after\n// SRT line: \"00:00:05,000 --> 00:00:07,000\"\nparseSrt({input: normalizedSrt});","handlingStrategy":"validation","validationCode":"const SRT_TS = /^\\d+:\\d{2}:\\d{2},\\d{3}$/;\nfunction isValidSrtTimestamp(ts: string): boolean {\n  return SRT_TS.test(ts.trim()) && ts.split(':')[0] !== '';\n}","typeGuard":"const hasHoursSegment = (ts: string): boolean => {\n  const first = ts.split(':')[0];\n  return first !== undefined && first !== '';\n};","tryCatchPattern":"try { parseSrt({input}); }\ncatch (e) {\n  if (e instanceof Error && /Invalid timestamp/.test(e.message)) {\n    input = normalizeSrtTimestamps(input);\n  }\n}","preventionTips":["Pre-validate SRT timestamps with a regex before parsing.","Use a conforming SRT export tool.","Reject files missing the hours component."],"tags":["captions","srt","parsing","validation","timestamp"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}