remotion-dev/remotion · error · TypeError
Audio data is not big enough to provide ${sampleSize} bars.
Error message
Audio data is not big enough to provide ${sampleSize} bars. What it means
Thrown by getVisualization when the provided audio data array is shorter than sampleSize. The FFT needs at least sampleSize samples to produce that many bars; with fewer samples the visualization cannot be computed and the guard fails fast instead of reading out of bounds.
Source
Thrown at packages/media-utils/src/fft/get-visualization.ts:43
sampleRate: number;
fps: number;
maxInt: number;
optimizeFor: OptimizeFor;
dataOffsetInSeconds: number;
}): number[] => {
const isPowerOfTwo = sampleSize > 0 && (sampleSize & (sampleSize - 1)) === 0;
if (!isPowerOfTwo) {
throw new TypeError(
`The argument "bars" must be a power of two. For example: 64, 128. Got instead: ${sampleSize}`,
);
}
if (!fps) {
throw new TypeError('The argument "fps" was not provided');
}
if (data.length < sampleSize) {
throw new TypeError(
'Audio data is not big enough to provide ' + sampleSize + ' bars.',
);
}
const start = Math.floor((frame / fps - dataOffsetInSeconds) * sampleRate);
const actualStart = Math.max(0, start - sampleSize / 2);
const ints = new Int16Array({
length: sampleSize,
});
ints.set(
data.subarray(actualStart, actualStart + sampleSize).map((x) => toInt16(x)),
);
const alg = optimizeFor === 'accuracy' ? fftAccurate : fftFast;
const phasors = alg(ints);
const magnitudes = fftMag(phasors).map((p) => p);View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Lower sampleSize so it fits within data.length (e.g. min(requestedBars, nextPow2(data.length))).
- Ensure the audio data covers enough duration: at least sampleSize / sampleRate seconds.
- Pad the data with zeros to the next power of two if a fixed sampleSize is required.
Example fix
// before
getVisualization({ sampleSize: 2048, data: shortFloat32, ... });
// after
const sampleSize = Math.min(2048, Math.pow(2, Math.floor(Math.log2(data.length))));
getVisualization({ sampleSize, data, ... }); Defensive patterns
Strategy: validation
Validate before calling
if (data.length < sampleSize) throw new TypeError(`need at least ${sampleSize} samples, got ${data.length}`);
getVisualization({ sampleSize, data, ...rest }); Type guard
const hasEnoughSamples = (data: Float32Array, n: number) => data.length >= n;
Try / catch
try { return getVisualization({ sampleSize, data, ...rest }); } catch (e) { if (/not big enough/.test(String((e as Error).message))) { const fit = Math.pow(2, Math.floor(Math.log2(data.length))); return getVisualization({ sampleSize: fit, data, ...rest }); } throw e; } Prevention
- Clamp sampleSize to the next power of two <= data.length.
- Ensure the audio clip is long enough for the requested bars.
- Zero-pad short data when a fixed sampleSize is mandatory.
When it happens
Trigger: Passing a Float32Array whose length is less than the requested number of bars (sampleSize). Happens when audio data is truncated, the sample window is too short, or sampleSize was increased beyond what the decoded audio provides.
Common situations: Very short audio clips where the decoded PCM is shorter than sampleSize. Requesting 2048 bars from a 1-second clip at low sample rate. A bug in data extraction that returns a subarray of the wrong length.
Related errors
- The argument "bars" must be a power of two. For example: 64,
- The argument "fps" was not provided
- No 'src' was passed to <Html5Audio>.
- No src passed
- The "freeze" prop is not supported on <Html5Audio />. Use <S
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/34f58143be1f4bbe.
Report an issue: GitHub.