{"record":{"id":"76ea1d7ab74791ea","repo":"remotion-dev/remotion","slug":"invalid-section-length","errorCode":null,"errorMessage":"Invalid section length","messagePattern":"Invalid section length","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/transport-stream/parse-pat.ts","lineNumber":58,"sourceCode":"\titerator.stopReadingBits();\n\n\treturn {\n\t\ttype: 'transport-stream-pat-box',\n\t\ttableId: tableId.toString(16),\n\t\tpat: tables,\n\t};\n};\n\nexport const parsePat = (iterator: BufferIterator): TransportStreamPATBox => {\n\titerator.startReadingBits();\n\n\tconst tableId = iterator.getBits(8);\n\titerator.getBits(1); // syntax indicator\n\titerator.getBits(1); // private bit\n\titerator.getBits(4);\n\tconst sectionLength = iterator.getBits(10);\n\tif (sectionLength > 1021) {\n\t\tthrow new Error('Invalid section length');\n\t}\n\n\titerator.stopReadingBits();\n\n\tconst tables = parsePatTable(iterator, tableId);\n\tdiscardRestOfPacket(iterator);\n\treturn tables;\n};\n\nexport const parseSdt = (iterator: BufferIterator): TransportStreamSdtBox => {\n\titerator.startReadingBits();\n\titerator.getBits(8); // table ID\n\titerator.getBits(1); // section syntax indicator\n\titerator.getBits(1); // private bit\n\titerator.getBits(2); // reserved\n\tconst sectionLength = iterator.getBits(12);\n\titerator.stopReadingBits();\n\titerator.discard(sectionLength);","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/transport-stream/parse-pat.ts#L40-L76","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Reject oversized PAT sections upstream using ffprobe\nimport {execSync} from 'node:child_process';\nfunction isValidTs(src: string): boolean {\n  try { execSync(`ffprobe -v error -i \"${src}\" -t 1 -f null -`, {stdio: 'ignore'}); return true; } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try { await parseMedia({src, fields: {dimensions: true}}); }\ncatch (e) { if (e instanceof Error && e.message === 'Invalid section length') { /* re-mux or reject */ } else throw e; }","preventionTips":["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."],"tags":["media-parser","transport-stream","mpegts","validation","container-format"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}