remotion-dev/remotion · error · Error

Invalid table ID: ${tableId}

Error message

Invalid table ID: ${tableId}

What it means

Thrown by parsePatTable when the PAT (Program Association Table) table_id field is not 0x00. Per ISO/IEC 13818-1, the PAT is identified exclusively by table_id = 0; any other value means the buffer does not actually contain a PAT. The library uses this guard to ensure parsePat is consuming the right packet before reading program associations.

Source

Thrown at packages/media-parser/src/containers/transport-stream/parse-pat.ts:24

export type TransportStreamProgramAssociationTableEntry = {
	type: 'transport-stream-program-association-table';
	programNumber: number;
	programMapIdentifier: number;
};

const parsePatTable = (
	iterator: BufferIterator,
	tableId: number,
): TransportStreamPATBox => {
	iterator.getUint16(); // table ID extension
	iterator.startReadingBits();
	iterator.getBits(7); // reserved
	iterator.getBits(1); // current / next indicator;
	const sectionNumber = iterator.getBits(8);
	const lastSectionNumber = iterator.getBits(8);
	if (tableId !== 0) {
		throw new Error('Invalid table ID: ' + tableId);
	}

	const tables: TransportStreamProgramAssociationTableEntry[] = [];
	for (let i = sectionNumber; i <= lastSectionNumber; i++) {
		const programNumber = iterator.getBits(16); // program number
		iterator.getBits(3); // reserved
		const programMapIdentifier = iterator.getBits(13); // program map PID

		tables.push({
			type: 'transport-stream-program-association-table',
			programNumber,
			programMapIdentifier,
		});
	}

	iterator.stopReadingBits();

	return {

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Re-mux or re-record the source .ts file with a conformant encoder (ffmpeg: ffmpeg -i in.ts -c copy -mpegts_pmt_version 0 out.ts).
  2. Verify the file with a reference tool such as ffprobe/mediainfo to confirm the PAT table_id is 0.
  3. If the file is intentionally non-standard, preprocess it (ffmpeg -i in.ts -map 0 -c copy out.ts) to normalize tables before feeding it to @remotion/media-parser.
  4. Handle the failure at the call site by treating the stream as unparseable and falling back to a different container or demuxer.

Example fix

// before
await parseMedia({src: corruptedUrl, fields: {dimensions: true}});

// after - validate file with ffprobe first, then fall back
try {
  await parseMedia({src, fields: {dimensions: true}});
} catch (e) {
  if (e.message === 'Invalid table ID: ' + someId) {
    // re-encode a clean copy
    await transcodeWithFfmpeg(src, cleanSrc);
    await parseMedia({src: cleanSrc, fields: {dimensions: true}});
  } else throw e;
}
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check a .ts file before handing it to parseMedia by demuxing with ffprobe
import {execSync} from 'node:child_process';
function hasValidPat(src: string): boolean {
  try {
    const out = execSync(`ffprobe -v error -show_streams -of json "${src}"`).toString();
    const json = JSON.parse(out);
    return Array.isArray(json.streams) && json.streams.length > 0;
  } catch { return false; }
}

Try / catch

try {
  await parseMedia({src, fields: {durationInSeconds: true}});
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Invalid table ID')) {
    // corrupt PAT - re-encode and retry once
    await transcode(src, src + '.remux.ts');
    await parseMedia({src: src + '.remux.ts', fields: {durationInSeconds: true}});
  } else throw e;
}

Prevention

When it happens

Trigger: parsePat() reads the first byte as tableId and forwards it to parsePatTable, which throws at parse-pat.ts:24 when tableId !== 0. Triggered when the parser routes a non-PAT packet (e.g. PMT table_id=2, SDT table_id=0x42) into parsePat, or when the MPEG-TS bitstream is corrupted so the leading byte of the section is not 0x00.

Common situations: Corrupt or truncated MPEG-TS files where the PAT packet payload is damaged; mis-demultiplexed .ts streams; files produced by broken encoders that write the wrong table_id; partial downloads where the PAT packet starts mid-payload.

Related errors


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