remotion-dev/remotion · error · Error
Invalid marker bits: ${markerBits}
Error message
Invalid marker bits: ${markerBits} What it means
Thrown at parse-pes.ts:28 when the two 'marker_bits' of a PES header (the first two bits after the PES_packet_length) are not equal to binary '10'. Per ISO/IEC 13818-1 these bits are fixed at '10' in MPEG-2; any deviation means the bytes are not a valid MPEG-2 PES header (possibly an MPEG-1 stream or corrupted data).
Source
Thrown at packages/media-parser/src/containers/transport-stream/parse-pes.ts:28
export const parsePes = ({
iterator,
offset,
}: {
iterator: BufferIterator;
offset: number;
}) => {
const ident = iterator.getUint24();
if (ident !== 0x000001) {
throw new Error(`Unexpected PES packet start code: ${ident.toString(16)}`);
}
const streamId = iterator.getUint8();
iterator.getUint16(); // PES packet length, is most of the time 0, so useless
iterator.startReadingBits();
const markerBits = iterator.getBits(2);
if (markerBits !== 0b10) {
throw new Error(`Invalid marker bits: ${markerBits}`);
}
const scrambled = iterator.getBits(2);
if (scrambled !== 0b00) {
throw new Error(`Only supporting non-scrambled streams`);
}
const priority = iterator.getBits(1);
iterator.getBits(1); // data alignment indicator
iterator.getBits(1); // copy right
iterator.getBits(1); // original or copy
const ptsPresent = iterator.getBits(1);
const dtsPresent = iterator.getBits(1);
if (!ptsPresent && dtsPresent) {
throw new Error(
`DTS is present but not PTS, this is not allowed in the spec`,
);
}View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Re-mux as MPEG-2 transport stream: ffmpeg -i in.mp4 -c copy -f mpegts out.ts.
- If the source is genuinely MPEG-1, transcode to a supported container/codec.
- Verify the PES header bytes with a hex dump or dvbsnoop.
- If the file parses in ffprobe but not here, file a bug with the sample attached.
Defensive patterns
Strategy: try-catch
Try / catch
try { await parseMedia({src: tsUrl}); }
catch (e) {
if (e instanceof Error && e.message.startsWith('Invalid marker bits')) {
// not a valid MPEG-2 PES - re-encode
await runFfmpeg(['-i', tsUrl, '-c:v', 'libx264', '-c:a', 'aac', '-f', 'mpegts', outUrl]);
await parseMedia({src: outUrl});
} else throw e;
} Prevention
- Ensure sources are muxed as MPEG-2 (not MPEG-1) transport streams.
- Re-encode legacy MPEG-1 content to MPEG-2/H.264 transport streams.
- Validate with ffprobe -show_format to confirm format=mpegts.
When it happens
Trigger: parsePes reads getBits(2) and compares to 0b10; mismatch throws. Triggered by MPEG-1 system streams (which use different marker conventions), by feeding a non-PES payload to parsePes, or by bit corruption in the PES header.
Common situations: Source files muxed as MPEG-1 instead of MPEG-2; corrupt captures from faulty encoders; misrouted elementary-stream bytes; partial files where the header bytes are missing.
Related errors
- Unexpected PES packet start code: ${ident.toString(16)}
- DTS is present but not PTS, this is not allowed in the spec
- Invalid PTS marker bits: ${fourBits}
- Invalid DTS marker bits: ${_fourBits}
- Invalid table ID: ${tableId}
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/5b5b8cbba834b5da.
Report an issue: GitHub.