remotion-dev/remotion · error · Error
Invalid section length
Error message
Invalid section length
What it means
Thrown at parse-pat.ts:58 when the PAT section_length field (10 bits) exceeds 1021 bytes. ISO/IEC 13818-1 caps section_length at 1021 (0x3FD) for ATSC/DVB, with the maximum theoretical 10-bit value being 1023 and the bottom reserved for CRC. Values above 1021 indicate a malformed section header.
Source
Thrown at packages/media-parser/src/containers/transport-stream/parse-pat.ts:58
iterator.stopReadingBits();
return {
type: 'transport-stream-pat-box',
tableId: tableId.toString(16),
pat: tables,
};
};
export const parsePat = (iterator: BufferIterator): TransportStreamPATBox => {
iterator.startReadingBits();
const tableId = iterator.getBits(8);
iterator.getBits(1); // syntax indicator
iterator.getBits(1); // private bit
iterator.getBits(4);
const sectionLength = iterator.getBits(10);
if (sectionLength > 1021) {
throw new Error('Invalid section length');
}
iterator.stopReadingBits();
const tables = parsePatTable(iterator, tableId);
discardRestOfPacket(iterator);
return tables;
};
export const parseSdt = (iterator: BufferIterator): TransportStreamSdtBox => {
iterator.startReadingBits();
iterator.getBits(8); // table ID
iterator.getBits(1); // section syntax indicator
iterator.getBits(1); // private bit
iterator.getBits(2); // reserved
const sectionLength = iterator.getBits(12);
iterator.stopReadingBits();
iterator.discard(sectionLength);View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Run the file through ffmpeg -i in.ts -c copy out.ts to rewrite clean PAT/PMT sections.
- Confirm with tsdiscont or dvbsnoop that the PAT section_length is within bounds.
- Re-acquire the source from the original encoder/broadcaster if it is a capture.
- Treat the file as unsupported and surface a user-facing error rather than retrying.
Defensive patterns
Strategy: validation
Validate before calling
// Reject oversized PAT sections upstream using ffprobe
import {execSync} from 'node:child_process';
function isValidTs(src: string): boolean {
try { execSync(`ffprobe -v error -i "${src}" -t 1 -f null -`, {stdio: 'ignore'}); return true; } catch { return false; }
} Try / catch
try { await parseMedia({src, fields: {dimensions: true}}); }
catch (e) { if (e instanceof Error && e.message === 'Invalid section length') { /* re-mux or reject */ } else throw e; } Prevention
- Pre-screen .ts inputs with ffprobe.
- Re-mux suspect files with ffmpeg -c copy to normalize section headers.
- Treat PAT/PMT validation errors as fatal rather than auto-retrying unchanged.
When it happens
Trigger: parsePat reads 1 + 1 + 1 + 4 + 10 bits and inspects sectionLength; if it is greater than 1021, parsing halts. Happens when the PAT section bytes are corrupted, when a PMT or other section is misread as a PAT, or when an 8-bit clean channel has flipped bits in the length field.
Common situations: Corrupted capture from a faulty DVB/ATSC tuner; bit-flips from a partially downloaded .ts; an encoder bug that writes the wrong section_length; packet loss where the PAT payload starts at the wrong offset.
Related errors
- Invalid table ID: ${tableId}
- Unexpected PES packet start code: ${ident.toString(16)}
- Invalid marker bits: ${markerBits}
- DTS is present but not PTS, this is not allowed in the spec
- Invalid PTS marker bits: ${fourBits}
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/76ea1d7ab74791ea.
Report an issue: GitHub.