{"record":{"id":"595d4bf8e9ec9190","repo":"remotion-dev/remotion","slug":"invalid-pts-marker-bits-fourbits","errorCode":null,"errorMessage":"Invalid PTS marker bits: ${fourBits}","messagePattern":"Invalid PTS marker bits: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/transport-stream/parse-pes.ts","lineNumber":63,"sourceCode":"\t\t);\n\t}\n\n\titerator.getBits(1); // escr flag\n\titerator.getBits(1); // es rate flag\n\titerator.getBits(1); // dsm trick mode flag\n\titerator.getBits(1); // additional copy info flag\n\titerator.getBits(1); // crc flag\n\titerator.getBits(1); // extension flag\n\tconst pesHeaderLength = iterator.getBits(8);\n\tconst offsetAfterHeader = iterator.counter.getOffset();\n\tlet pts: number | null = null;\n\tif (!ptsPresent) {\n\t\tthrow new Error(`PTS is required`);\n\t}\n\n\tconst fourBits = iterator.getBits(4);\n\tif (fourBits !== 0b0011 && fourBits !== 0b0010) {\n\t\tthrow new Error(`Invalid PTS marker bits: ${fourBits}`);\n\t}\n\n\tconst pts1 = iterator.getBits(3);\n\titerator.getBits(1); // marker bit\n\tconst pts2 = iterator.getBits(15);\n\titerator.getBits(1); // marker bit\n\tconst pts3 = iterator.getBits(15);\n\titerator.getBits(1); // marker bit\n\tpts = (pts1 << 30) | (pts2 << 15) | pts3;\n\n\tlet dts: number | null = null;\n\tif (dtsPresent) {\n\t\tconst _fourBits = iterator.getBits(4);\n\t\tif (_fourBits !== 0b0001) {\n\t\t\tthrow new Error(`Invalid DTS marker bits: ${_fourBits}`);\n\t\t}\n\n\t\tconst dts1 = iterator.getBits(3);","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/transport-stream/parse-pes.ts#L45-L81","documentation":"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.","triggerScenarios":"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.","commonSituations":"Corrupted .ts captures; partial packets where the PTS bytes are missing; faulty hardware encoders; bit-flips from a noisy transport channel.","solutions":["Re-mux the file: ffmpeg -i in.ts -c copy out.ts.","Validate PTS values with ffprobe -show_frames and confirm prefix bytes.","Re-acquire the source if it is a damaged broadcast capture.","Report a bug to @remotion/media-parser with a sample if the file plays in VLC/ffprobe."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await parseMedia({src}); }\ncatch (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; }","preventionTips":["Re-mux corrupt .ts files before parsing.","Validate PTS with ffprobe -show_frames.","Treat persistent PTS-prefix errors as damaged-source rather than retrying unchanged."],"tags":["media-parser","transport-stream","mpegts","pes","pts","validation"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}