remotion-dev/remotion · error · Error

Invalid timestamp:${time}

Error message

Invalid timestamp:${time}

What it means

`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.

Source

Thrown at packages/captions/src/parse-srt.ts:6

import type {Caption} from './caption';

function toSeconds(time: string) {
	const [first, second, third] = time.split(':');
	if (!first) {
		throw new Error(`Invalid timestamp:${time}`);
	}

	if (!second) {
		throw new Error(`Invalid timestamp:${time}`);
	}

	if (!third) {
		throw new Error(`Invalid timestamp:${time}`);
	}

	const [seconds, millis] = third.split(',');
	if (!seconds) {
		throw new Error(`Invalid timestamp:${time}`);
	}

	if (!millis) {
		throw new Error(`Invalid timestamp:${time}`);
	}

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Ensure timestamps follow SRT format HH:MM:SS,mmm (hours required).
  2. Pre-validate timestamps with a regex like /^\d+:\d{2}:\d{2},\d{3}$/.
  3. If using VTT, convert to SRT format or use a VTT parser.
  4. Normalize empty segments before parsing.

Example fix

// before
// SRT line: ":00:05,000 --> :00:07,000"
parseSrt({input: srtWithBadTimestamps});

// after
// SRT line: "00:00:05,000 --> 00:00:07,000"
parseSrt({input: normalizedSrt});
Defensive patterns

Strategy: validation

Validate before calling

const SRT_TS = /^\d+:\d{2}:\d{2},\d{3}$/;
function isValidSrtTimestamp(ts: string): boolean {
  return SRT_TS.test(ts.trim()) && ts.split(':')[0] !== '';
}

Type guard

const hasHoursSegment = (ts: string): boolean => {
  const first = ts.split(':')[0];
  return first !== undefined && first !== '';
};

Try / catch

try { parseSrt({input}); }
catch (e) {
  if (e instanceof Error && /Invalid timestamp/.test(e.message)) {
    input = normalizeSrtTimestamps(input);
  }
}

Prevention

When it happens

Trigger: 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`.

Common situations: 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.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/404c75c8cc3d7c73. Report an issue: GitHub.