{"record":{"id":"65481f94cef06b51","repo":"remotion-dev/remotion","slug":"invalid-syncword-syncword","errorCode":null,"errorMessage":"Invalid syncword: ${syncWord}","messagePattern":"Invalid syncword: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/aac/parse-aac.ts","lineNumber":19,"sourceCode":"import {\n\tcreateAacCodecPrivate,\n\tgetSampleRateFromSampleFrequencyIndex,\n\tmapAudioObjectTypeToCodecString,\n} from '../../aac-codecprivate';\nimport {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,","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/aac/parse-aac.ts#L1-L37","documentation":"Thrown by the ADTS AAC parser (parseAac) when the first 12 bits of a frame are not the sync word 0xFFF. ADTS (Audio Data Transport Stream) frames must begin with this 12-bit sync pattern; its absence means the byte stream is either not ADTS AAC, is corrupted, or the parser's read position has drifted and is no longer aligned to a frame boundary.","triggerScenarios":"Calling parseMedia on a .aac file (or raw ADTS stream) where the first 12 bits at the parse position are not 0xFFF. Occurs with non-ADTS streams (e.g. raw AAC frames without transport headers, or MP4-wrapped AAC being read as raw), truncated files, or bit-flipped/corrupted headers.","commonSituations":"Passing an MP4/M4A file that contains AAC inside an MP4 container but is being parsed as a raw .aac stream. Files with corrupted headers from incomplete downloads. Files that are actually a different format but have a .aac extension. Files with padding or metadata prepended before the first ADTS frame.","solutions":["Verify the file is genuinely raw ADTS AAC: `ffprobe input.aac` and confirm it reports 'ADTS AAC'.","If the file is MP4/M4A-wrapped, remove the .aac extension or pass the correct container; parseMedia auto-detects containers.","Re-mux or re-extract raw AAC: `ffmpeg -i input.mp4 -c:a copy -f adts output.aac`.","Switch to Mediabunny (https://www.remotion.dev/docs/mediabunny/metadata) for more robust parsing.","Report the file to Remotion if ffprobe can parse it but parseMedia cannot."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check: verify file starts with ADTS sync word 0xFFF\nimport {readFile} from 'fs/promises';\n\nasync function isValidAdtsAac(filePath: string): Promise<boolean> {\n  const buf = await readFile(filePath);\n  if (buf.length < 2) return false;\n  return (buf[0] === 0xff) && (buf[1] & 0xf0) === 0xf0;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const result = await parseMedia({src, fields: {/* ... */}});\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Invalid syncword')) {\n    console.error('File is not valid ADTS AAC. Verify the format with: ffprobe <file>');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Verify the file format with ffprobe before passing to parseMedia.","Ensure .aac files contain raw ADTS streams, not MP4-wrapped AAC.","If extracting AAC from MP4, use ffmpeg -f adts to produce proper ADTS output.","Migrate to Mediabunny for more robust container auto-detection."],"tags":["aac","adts","media-parser","sync-word","corrupt-file","container-detection"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}