remotion-dev/remotion · error · Error

Invalid PTS marker bits: ${fourBits}

Error message

Invalid PTS marker bits: ${fourBits}

What it means

Thrown at parse-pes.ts:63 when the 4-bit prefix of the PTS field ('0010' for PTS-only or '0011' for PTS+DTS) is neither 0b0011 nor 0b0010. This prefix is fixed by ISO/IEC 13818-1; any other value means the PTS encoding is corrupt.

Source

Thrown at packages/media-parser/src/containers/transport-stream/parse-pes.ts:63

		);
	}

	iterator.getBits(1); // escr flag
	iterator.getBits(1); // es rate flag
	iterator.getBits(1); // dsm trick mode flag
	iterator.getBits(1); // additional copy info flag
	iterator.getBits(1); // crc flag
	iterator.getBits(1); // extension flag
	const pesHeaderLength = iterator.getBits(8);
	const offsetAfterHeader = iterator.counter.getOffset();
	let pts: number | null = null;
	if (!ptsPresent) {
		throw new Error(`PTS is required`);
	}

	const fourBits = iterator.getBits(4);
	if (fourBits !== 0b0011 && fourBits !== 0b0010) {
		throw new Error(`Invalid PTS marker bits: ${fourBits}`);
	}

	const pts1 = iterator.getBits(3);
	iterator.getBits(1); // marker bit
	const pts2 = iterator.getBits(15);
	iterator.getBits(1); // marker bit
	const pts3 = iterator.getBits(15);
	iterator.getBits(1); // marker bit
	pts = (pts1 << 30) | (pts2 << 15) | pts3;

	let dts: number | null = null;
	if (dtsPresent) {
		const _fourBits = iterator.getBits(4);
		if (_fourBits !== 0b0001) {
			throw new Error(`Invalid DTS marker bits: ${_fourBits}`);
		}

		const dts1 = iterator.getBits(3);

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Re-mux the file: ffmpeg -i in.ts -c copy out.ts.
  2. Validate PTS values with ffprobe -show_frames and confirm prefix bytes.
  3. Re-acquire the source if it is a damaged broadcast capture.
  4. Report a bug to @remotion/media-parser with a sample if the file plays in VLC/ffprobe.
Defensive patterns

Strategy: try-catch

Try / catch

try { await parseMedia({src}); }
catch (e) { if (e instanceof Error && e.message.startsWith('Invalid PTS marker bits')) { await runFfmpeg(['-i', src, '-c', 'copy', src + '.remux.ts']); await parseMedia({src: src + '.remux.ts'}); } else throw e; }

Prevention

When it happens

Trigger: parsePes reads getBits(4) into 'fourBits' immediately after the PES header and validates it against the allowed prefixes. Triggered by bit corruption in the PTS field, a truncated PES header, or an encoder that mis-wrote the prefix.

Common situations: Corrupted .ts captures; partial packets where the PTS bytes are missing; faulty hardware encoders; bit-flips from a noisy transport channel.

Related errors


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