remotion-dev/remotion · error · Error
Invalid PTS marker bits: ${fourBits}
Error message
Invalid PTS marker bits: ${fourBits} What it means
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.
Source
Thrown at packages/media-parser/src/containers/transport-stream/parse-pes.ts:63
);
}
iterator.getBits(1); // escr flag
iterator.getBits(1); // es rate flag
iterator.getBits(1); // dsm trick mode flag
iterator.getBits(1); // additional copy info flag
iterator.getBits(1); // crc flag
iterator.getBits(1); // extension flag
const pesHeaderLength = iterator.getBits(8);
const offsetAfterHeader = iterator.counter.getOffset();
let pts: number | null = null;
if (!ptsPresent) {
throw new Error(`PTS is required`);
}
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);View on GitHub (pinned to 78fe4bb3fd)
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.
Defensive patterns
Strategy: try-catch
Try / catch
try { await parseMedia({src}); }
catch (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; } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Corrupted .ts captures; partial packets where the PTS bytes are missing; faulty hardware encoders; bit-flips from a noisy transport channel.
Related errors
- DTS is present but not PTS, this is not allowed in the spec
- Unexpected PES packet start code: ${ident.toString(16)}
- Invalid marker bits: ${markerBits}
- PTS is required
- Invalid DTS marker bits: ${_fourBits}
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/595d4bf8e9ec9190.
Report an issue: GitHub.