{"record":{"id":"cff468dda15d97be","repo":"remotion-dev/remotion","slug":"only-supporting-mpeg-4-for-aac","errorCode":null,"errorMessage":"Only supporting MPEG-4 for .aac","messagePattern":"Only supporting MPEG-4 for \\.aac","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/aac/parse-aac.ts","lineNumber":24,"sourceCode":"import {convertAudioOrVideoSampleToWebCodecsTimestamps} from '../../convert-audio-or-video-sample';\nimport type {ParseResult} from '../../parse-result';\nimport {registerAudioTrack} from '../../register-track';\nimport type {ParserState} from '../../state/parser-state';\nimport {WEBCODECS_TIMESCALE} from '../../webcodecs-timescale';\n\nexport const parseAac = async (state: ParserState): Promise<ParseResult> => {\n\tconst {iterator} = state;\n\tconst startOffset = iterator.counter.getOffset();\n\n\titerator.startReadingBits();\n\tconst syncWord = iterator.getBits(12);\n\tif (syncWord !== 0xfff) {\n\t\tthrow new Error('Invalid syncword: ' + syncWord);\n\t}\n\n\tconst id = iterator.getBits(1);\n\tif (id !== 0) {\n\t\tthrow new Error('Only supporting MPEG-4 for .aac');\n\t}\n\n\tconst layer = iterator.getBits(2);\n\tif (layer !== 0) {\n\t\tthrow new Error('Only supporting layer 0 for .aac');\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":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/aac/parse-aac.ts#L6-L42","documentation":"Thrown by parseAac when the MPEG 'ID' bit in an ADTS header is 1, meaning the stream is MPEG-2 (ISO 13818-7) rather than MPEG-4 (ISO 14496-3). The parser only supports MPEG-4 AAC, so it rejects MPEG-2 streams. This is a deliberate scope limitation of the @remotion/media-parser ADTS parser.","triggerScenarios":"Parsing a .aac file whose ADTS frames carry the MPEG-2 ID bit set (id=1). This occurs with legacy MPEG-2 AAC files or files produced by older encoders that default to MPEG-2 transport.","commonSituations":"Legacy audio files encoded with old tools (e.g. early FAAD/FAAC builds) that default to MPEG-2 AAC. Files from older broadcast or telephony systems. Some test suites still ship MPEG-2 AAC samples.","solutions":["Re-encode to MPEG-4 AAC: `ffmpeg -i input.aac -c:a aac -f adts output.aac` (ffmpeg defaults to MPEG-4 ID).","Switch to Mediabunny (https://www.remotion.dev/docs/mediabunny/metadata) which may support MPEG-2 AAC.","If you cannot re-encode, use ffprobe to extract metadata instead of @remotion/media-parser.","Report the file to the Remotion team to gauge whether MPEG-2 support is worth adding."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check: verify MPEG-4 ID bit (bit 12 of ADTS header is 0)\nasync function isMpeg4Adts(filePath: string): Promise<boolean> {\n  const buf = await readFile(filePath);\n  if (buf.length < 2) return false;\n  // Byte 1, bit 3 (0-indexed from MSB) = ID bit; should be 0 for MPEG-4\n  return (buf[1] & 0x08) === 0x00;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const result = await parseMedia({src, fields: {/* ... */}});\n} catch (e) {\n  if (e instanceof Error && e.message === 'Only supporting MPEG-4 for .aac') {\n    console.error('File is MPEG-2 AAC. Re-encode: ffmpeg -i input.aac -c:a aac -f adts output.aac');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Re-encode legacy MPEG-2 AAC files to MPEG-4 with ffmpeg before parsing.","Check the ADTS ID bit before batch processing .aac files.","Use ffprobe to confirm 'codec_tag' and MPEG version.","Migrate to Mediabunny which may support MPEG-2 AAC."],"tags":["aac","adts","media-parser","mpeg-2","unsupported-format"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}