remotion-dev/remotion · error · Error

Invalid DTS marker bits: ${_fourBits}

Error message

Invalid DTS marker bits: ${_fourBits}

What it means

Thrown at parse-pes.ts:78 when the 4-bit prefix of the DTS field is not 0b0001. The DTS prefix is fixed at '0001' by ISO/IEC 13818-1 whenever DTS is present; any other value means the DTS encoding is invalid.

Source

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

	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);
		iterator.getBits(1); // marker bit
		const dts2 = iterator.getBits(15);
		iterator.getBits(1); // marker bit
		const dts3 = iterator.getBits(15);
		iterator.getBits(1); // marker bit
		dts = (dts1 << 30) | (dts2 << 15) | dts3;
	}

	iterator.stopReadingBits();
	iterator.discard(
		pesHeaderLength - (iterator.counter.getOffset() - offsetAfterHeader),
	);

	const packet: PacketPes = {
		dts,

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Re-mux the file: ffmpeg -i in.ts -c copy out.ts.
  2. Validate DTS values with ffprobe -show_frames.
  3. Re-acquire the source if it is a damaged capture.
  4. File a bug with a sample if the file is otherwise playable in reference tools.
Defensive patterns

Strategy: try-catch

Try / catch

try { await parseMedia({src}); }
catch (e) { if (e instanceof Error && e.message.startsWith('Invalid DTS 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: Inside the dtsPresent branch, parsePes reads getBits(4) into _fourBits and compares to 0b0001. Triggered by corruption in the DTS field, a truncated header, or a muxer that mis-wrote the prefix.

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

Related errors


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