{"record":{"id":"10ec641f1eb68d68","repo":"remotion-dev/remotion","slug":"only-supporting-mpeg-4-for-ts","errorCode":null,"errorMessage":"Only supporting MPEG-4 for .ts","messagePattern":"Only supporting MPEG-4 for \\.ts","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/transport-stream/adts-header.ts","lineNumber":27,"sourceCode":"\t\treturn null;\n\t}\n\n\tconst iterator = getArrayBufferIterator({\n\t\tinitialData: buffer,\n\t\tmaxBytes: buffer.byteLength,\n\t\tlogLevel: 'error',\n\t});\n\n\titerator.startReadingBits();\n\tconst bits = iterator.getBits(12);\n\tif (bits !== 0xfff) {\n\t\tthrow new Error('Invalid ADTS header ');\n\t}\n\n\t// MPEG Version, set to 0 for MPEG-4 and 1 for MPEG-2.\n\tconst id = iterator.getBits(1);\n\tif (id !== 0) {\n\t\tthrow new Error('Only supporting MPEG-4 for .ts');\n\t}\n\n\tconst layer = iterator.getBits(2);\n\tif (layer !== 0) {\n\t\tthrow new Error('Only supporting layer 0 for .ts');\n\t}\n\n\tconst protectionAbsent = iterator.getBits(1); // protection absent\n\tconst audioObjectType = iterator.getBits(2); // 1 = 'AAC-LC'\n\n\tconst samplingFrequencyIndex = iterator.getBits(4);\n\tconst sampleRate = getSampleRateFromSampleFrequencyIndex(\n\t\tsamplingFrequencyIndex,\n\t);\n\titerator.getBits(1); // private bit\n\tconst channelConfiguration = iterator.getBits(3);\n\tconst codecPrivate = createAacCodecPrivate({\n\t\taudioObjectType,","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/transport-stream/adts-header.ts#L9-L45","documentation":"Thrown by readAdtsHeader() when the ADTS 'id' bit is 1, meaning MPEG-2 (ISO/IEC 13818-7) ADTS rather than MPEG-4 (ISO/IEC 14496-3). The parser only handles the MPEG-4 variant (id == 0). The bit is read right after the 12-bit sync word.","triggerScenarios":"An ADTS stream authored as MPEG-2 AAC (id bit set). Some older encoders and broadcast chains emit MPEG-2 ADTS.","commonSituations":"Older broadcast TS content, files produced by legacy AAC encoders, or content authored with tools that default to MPEG-2 ADTS.","solutions":["Re-encode the AAC to MPEG-4 ADTS: ffmpeg -i in.ts -c:a aac -mpegts_flags +mod0 out.ts (or simply re-encode AAC: ffmpeg -i in.ts -c:v copy -c:a aac out.ts).","Confirm the ADTS variant with ffprobe; if MPEG-2 ADTS is required, transcode before parsing.","Reject such files at ingest and request an MPEG-4 variant."],"exampleFix":"// before\nawait parseMediaStream({src: 'mpeg2adts.ts'});\n\n// after: re-encode audio as MPEG-4 AAC\n// ffmpeg -i mpeg2adts.ts -c:v copy -c:a aac -tag:a aac out.ts\nawait parseMediaStream({src: 'out.ts'});","handlingStrategy":"validation","validationCode":"// Inspect the ADTS id bit (MPEG-4 vs MPEG-2) before parsing.\nfunction isMpeg4Adts(buf: Uint8Array): boolean {\n  // byte 1, bit 3 (after 12-bit sync): id == 0 means MPEG-4\n  return buf.length >= 2 && (buf[1] & 0x08) === 0;\n}\nif (!isMpeg4Adts(buffer)) {\n  throw new Error('Rejecting MPEG-2 ADTS — re-encode as MPEG-4');\n}","typeGuard":"function isMpeg4Adts(buf: Uint8Array): boolean {\n  return buf.length >= 2 && (buf[1] & 0x08) === 0;\n}","tryCatchPattern":"try {\n  const hdr = readAdtsHeader(buffer);\n} catch (err) {\n  if (err instanceof Error && err.message === 'Only supporting MPEG-4 for .ts') {\n    // re-encode AAC: ffmpeg -i in.ts -c:v copy -c:a aac out.ts\n  } else throw err;\n}","preventionTips":["Author AAC as MPEG-4 ADTS (id bit = 0).","Use ffmpeg to re-encode MPEG-2 ADTS to MPEG-4.","Validate ADTS variant with ffprobe before parsing."],"tags":["transport-stream","adts","aac","mpeg-2","unsupported-format","media-parser"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}