{"record":{"id":"d7d046825e33f094","repo":"remotion-dev/remotion","slug":"unexpected-sampling-frequency-index-samplingfreq","errorCode":null,"errorMessage":"Unexpected sampling frequency index ${samplingFrequencyIndex}","messagePattern":"Unexpected sampling frequency index (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/aac-codecprivate.ts","lineNumber":32,"sourceCode":"\t\t\treturn 44100;\n\t\tcase 5:\n\t\t\treturn 32000;\n\t\tcase 6:\n\t\t\treturn 24000;\n\t\tcase 7:\n\t\t\treturn 22050;\n\t\tcase 8:\n\t\t\treturn 16000;\n\t\tcase 9:\n\t\t\treturn 12000;\n\t\tcase 10:\n\t\t\treturn 11025;\n\t\tcase 11:\n\t\t\treturn 8000;\n\t\tcase 12:\n\t\t\treturn 7350;\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`Unexpected sampling frequency index ${samplingFrequencyIndex}`,\n\t\t\t);\n\t}\n};\n\n// codec private, for example [17, 144]\n// audioObjectType = 2 = 'AAC LC'\n// samplingFrequencyIndex = 3 = '48000 Hz'\n// channelConfiguration = 2 = '2 channels'\n/**\n * bytes 17,144: 00010 001 | 1 0010 000\n                 ^^^^^ ^^^   ^ ^^^^ ^\n                 |     |       |    | padding\n                 |     |       |\n                 |     |       +-- channelConfiguration (2)\n                 |     +-- samplingFrequencyIndex (3)\n                 +-- audioConfigType (2)\n  */","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/aac-codecprivate.ts#L14-L50","documentation":"Thrown by getSampleRateFromSampleFrequencyIndex in @remotion/media-parser when parsing AAC codec private data whose 4-bit sampling frequency index is not one of the 13 valid MPEG-4 AAC values (0x0-0xC), and is not the escape value 0xF (handled separately). This indicates malformed or unsupported AAC metadata in the source file.","triggerScenarios":"A media file whose AAC audio track advertises a sampling_frequency_index outside the range 0-12 (and not 0xF, which triggers the 24-bit extension path). Typically a corrupt or non-standard AAC stream encountered during parsing.","commonSituations":"A truncated or corrupt MP4/M4A file, an audio track produced by a non-standard encoder, or a file with damaged atoms/headers. Rare in well-authored files; usually points to file corruption.","solutions":["Re-encode the audio track with a standard encoder: ffmpeg -i in.mp4 -c:a aac -b:a 128k out.mp4.","Use a different, well-formed source file.","If you control the source pipeline, ensure the encoder emits a standard sampling frequency (96000 down to 7350 Hz)."],"exampleFix":"# before: file with corrupt AAC metadata\nremotion render --props='{\"src\":\"bad.m4a\"}'\n\n# after: re-encode audio\nffmpeg -i bad.m4a -c:a aac -b:a 128k -ar 48000 good.m4a\nremotion render --props='{\"src\":\"good.m4a\"}'","handlingStrategy":"try-catch","validationCode":"null","typeGuard":null,"tryCatchPattern":"// Media parsing is internal; catch at the render boundary and re-encode:\ntry {\n  await renderMedia(...);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('sampling frequency index')) {\n    // re-encode the offending audio track\n  }\n  throw e;\n}","preventionTips":["Re-encode audio with a standard encoder before use.","Run ffprobe on sources to validate AAC metadata.","Reject corrupt or non-standard audio files at ingestion."],"tags":["aac","audio","media-parser","corrupt-file","codec"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}