remotion-dev/remotion · error
Only supporting layer 0 for .ts
Error message
Only supporting layer 0 for .ts
What it means
Thrown by readAdtsHeader() when the 2-bit ADTS 'layer' field is not 0. Per the MPEG-4 ADTS spec the layer field is always 00 (reserved/unused); any other value indicates a corrupt header or non-ADTS data.
Source
Thrown at packages/media-parser/src/containers/transport-stream/adts-header.ts:32
maxBytes: buffer.byteLength,
logLevel: 'error',
});
iterator.startReadingBits();
const bits = iterator.getBits(12);
if (bits !== 0xfff) {
throw new Error('Invalid ADTS header ');
}
// MPEG Version, set to 0 for MPEG-4 and 1 for MPEG-2.
const id = iterator.getBits(1);
if (id !== 0) {
throw new Error('Only supporting MPEG-4 for .ts');
}
const layer = iterator.getBits(2);
if (layer !== 0) {
throw new Error('Only supporting layer 0 for .ts');
}
const protectionAbsent = iterator.getBits(1); // protection absent
const audioObjectType = iterator.getBits(2); // 1 = 'AAC-LC'
const samplingFrequencyIndex = iterator.getBits(4);
const sampleRate = getSampleRateFromSampleFrequencyIndex(
samplingFrequencyIndex,
);
iterator.getBits(1); // private bit
const channelConfiguration = iterator.getBits(3);
const codecPrivate = createAacCodecPrivate({
audioObjectType,
sampleRate,
channelConfiguration,
codecPrivate: null,
});
iterator.getBits(1); // originalityView on GitHub (pinned to 78fe4bb3fd)
Solutions
- Re-acquire or re-encode the TS stream: ffmpeg -i in.ts -c copy out.ts (re-mux) or ffmpeg -i in.ts -c:a aac out.ts (re-encode AAC).
- Resync the ADTS reader to the next 0xFFF sync word before retrying.
- Validate the stream with ffprobe before parsing.
Defensive patterns
Strategy: validation
Validate before calling
// The ADTS layer field must be 00 (bits 2..3 of byte 1).
function isAdtsLayerZero(buf: Uint8Array): boolean {
return buf.length >= 2 && (buf[1] & 0x06) === 0;
}
if (!isAdtsLayerZero(buffer)) {
// corrupt header — resync or re-encode
} Type guard
function isAdtsLayerZero(buf: Uint8Array): boolean {
return buf.length >= 2 && (buf[1] & 0x06) === 0;
} Try / catch
try {
const hdr = readAdtsHeader(buffer);
} catch (err) {
if (err instanceof Error && err.message === 'Only supporting layer 0 for .ts') {
// corrupt header: resync to next 0xFFF and retry
} else throw err;
} Prevention
- Treat a non-zero ADTS layer as corruption and resync.
- Re-encode suspect TS files with ffmpeg to regenerate clean ADTS.
- Validate streams with ffprobe before parsing.
When it happens
Trigger: A corrupt ADTS header where the layer bits are non-zero, almost always caused by bit-flips or misaligned reading rather than a legitimately different stream — valid ADTS always has layer == 0.
Common situations: Corrupt TS payload, misaligned ADTS read, bit errors in transport, or random data being parsed as ADTS.
Related errors
- Invalid ADTS header
- Only supporting MPEG-4 for .ts
- Invalid ADTS header - too short
- Expected length is null
- Expected length is greater than stream buffer length
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/b643f65183ef1c71.
Report an issue: GitHub.