{"record":{"id":"4bb141347be214e9","repo":"remotion-dev/remotion","slug":"sample-rate-not-found","errorCode":null,"errorMessage":"Sample rate not found","messagePattern":"Sample rate not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/flac/get-sample-rate.ts","lineNumber":16,"sourceCode":"import type {BufferIterator} from '../../iterator/buffer-iterator';\nimport type {ParserState} from '../../state/parser-state';\n\n// https://www.rfc-editor.org/rfc/rfc9639.html#name-sample-rate-bits\nexport const getSampleRate = (\n\titerator: BufferIterator,\n\tstate: ParserState,\n): number | 'uncommon-u8' | 'uncommon-u16' | 'uncommon-u16-10' => {\n\tconst mode = iterator.getBits(4);\n\tif (mode === 0b0000 || mode === 0b1111) {\n\t\tconst structure = state.structure.getFlacStructure();\n\t\tconst sampleRate =\n\t\t\tstructure.boxes.find((box) => box.type === 'flac-streaminfo')\n\t\t\t\t?.sampleRate ?? null;\n\t\tif (sampleRate === null) {\n\t\t\tthrow new Error('Sample rate not found');\n\t\t}\n\n\t\treturn sampleRate;\n\t}\n\n\tif (mode === 0b0001) {\n\t\treturn 88200;\n\t}\n\n\tif (mode === 0b0010) {\n\t\treturn 176400;\n\t}\n\n\tif (mode === 0b0011) {\n\t\treturn 192000;\n\t}\n\n\tif (mode === 0b0100) {","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/flac/get-sample-rate.ts#L1-L34","documentation":"Thrown by getSampleRate() when the FLAC frame header's sample-rate mode is 0b0000 or 0b1111 (meaning 'get from STREAMINFO'), but no flac-streaminfo box with a sampleRate field exists in the parsed structure. The parser falls back to the STREAMINFO block for the sample rate in these modes; if STREAMINFO was never parsed or lacks the field, it cannot determine the rate.","triggerScenarios":"Parsing a FLAC frame whose sample-rate bits are 0b0000 or 0b1111 (inheriting from STREAMINFO) while the STREAMINFO block is missing from the structure. This happens when the metadata header was not fully parsed before frame parsing began, or when the STREAMINFO block is corrupt/absent.","commonSituations":"Truncated or corrupt FLAC files where the STREAMINFO metadata block is missing but frame data is present. Files where the parser skipped or failed during metadata header parsing. Rarely, a race condition in streaming/incremental parsing where frames arrive before STREAMINFO is registered.","solutions":["Verify the file with `ffprobe input.flac` to confirm it has a valid STREAMINFO block.","Re-encode from a known-good source to repair the metadata: `ffmpeg -i input.flac output.flac`.","Switch to Mediabunny (https://www.remotion.dev/docs/mediabunny/metadata).","Ensure the entire FLAC header (including STREAMINFO) is fed to the parser before frame data."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const result = await parseMedia({src, fields: {sampleRate: true}});\n} catch (e) {\n  if (e instanceof Error && e.message === 'Sample rate not found') {\n    console.error('FLAC STREAMINFO missing sample rate. File is likely corrupt. Run: ffprobe <file>');\n  } else {\n    throw e;\n  }\n}","preventionTips":["Validate FLAC file integrity with ffprobe before parsing.","Ensure the complete file (including metadata header) is available to the parser.","Re-encode corrupt FLAC files: ffmpeg -i input.flac output.flac.","Migrate to Mediabunny for more robust FLAC metadata handling."],"tags":["flac","media-parser","sample-rate","streaminfo","missing-metadata"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}