remotion-dev/remotion · error
Sample rate not found
Error message
Sample rate not found
What it means
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.
Source
Thrown at packages/media-parser/src/containers/flac/get-sample-rate.ts:16
import type {BufferIterator} from '../../iterator/buffer-iterator';
import type {ParserState} from '../../state/parser-state';
// https://www.rfc-editor.org/rfc/rfc9639.html#name-sample-rate-bits
export const getSampleRate = (
iterator: BufferIterator,
state: ParserState,
): number | 'uncommon-u8' | 'uncommon-u16' | 'uncommon-u16-10' => {
const mode = iterator.getBits(4);
if (mode === 0b0000 || mode === 0b1111) {
const structure = state.structure.getFlacStructure();
const sampleRate =
structure.boxes.find((box) => box.type === 'flac-streaminfo')
?.sampleRate ?? null;
if (sampleRate === null) {
throw new Error('Sample rate not found');
}
return sampleRate;
}
if (mode === 0b0001) {
return 88200;
}
if (mode === 0b0010) {
return 176400;
}
if (mode === 0b0011) {
return 192000;
}
if (mode === 0b0100) {View on GitHub (pinned to 78fe4bb3fd)
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.
Defensive patterns
Strategy: try-catch
Try / catch
try {
const result = await parseMedia({src, fields: {sampleRate: true}});
} catch (e) {
if (e instanceof Error && e.message === 'Sample rate not found') {
console.error('FLAC STREAMINFO missing sample rate. File is likely corrupt. Run: ffprobe <file>');
} else {
throw e;
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Streaminfo not found
- Stream info not found
- Expected flac-streaminfo
- Invalid sample rate mode: ${mode.toString(2)}
- Unexpected sample rate ${sampleRate}
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/4bb141347be214e9.
Report an issue: GitHub.