remotion-dev/remotion · error
Only supporting fixed count type in stsz box
Error message
Only supporting fixed count type in stsz box
What it means
Thrown by getGroupedSamplesPositionsFromMp4 when the stsz box's countType is not 'fixed'. A 'fixed' stsz declares one sample size applied to every sample, which lets the parser multiply by samples-per-chunk. A 'variable' stsz (per-sample sizes) is not handled by this grouped-samples fast path, so it refuses rather than compute incorrect offsets.
Source
Thrown at packages/media-parser/src/get-sample-positions-from-mp4.ts:38
}): SamplePosition[] => {
const stscBox = getStscBox(trakBox);
const stszBox = getStszBox(trakBox);
const stcoBox = getStcoBox(trakBox);
if (!stscBox) {
throw new Error('Expected stsc box in trak box');
}
if (!stcoBox) {
throw new Error('Expected stco box in trak box');
}
if (!stszBox) {
throw new Error('Expected stsz box in trak box');
}
if (stszBox.countType !== 'fixed') {
throw new Error('Only supporting fixed count type in stsz box');
}
const samples: SamplePosition[] = [];
let timestamp = 0;
const stscKeys = Array.from(stscBox.entries.keys());
for (let i = 0; i < stcoBox.entries.length; i++) {
const entry = stcoBox.entries[i];
const chunk = i + 1;
const stscEntry = stscKeys.findLast((e) => e <= chunk);
if (stscEntry === undefined) {
throw new Error('should not be');
}
const samplesPerChunk = stscBox.entries.get(stscEntry);
if (samplesPerChunk === undefined) {
throw new Error('should not be');View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Use the general sample-positions path (not the grouped variant) for tracks with variable sample sizes.
- Only call getGroupedSamplesPositionsFromMp4 for tracks known to have fixed sample sizes (check stszBox.countType === 'fixed' first).
- Confirm the track type; for compressed codecs prefer getSamplePositionsFromTrack.
Example fix
// before
const positions = getGroupedSamplesPositionsFromMp4({trakBox, bigEndian});
// after
const stszBox = getStszBox(trakBox);
if (stszBox?.countType === 'fixed') {
const positions = getGroupedSamplesPositionsFromMp4({trakBox, bigEndian});
} else {
// use the general variable-size sample path
const positions = getSamplePositionsFromTrack({trakBox, ...});
} Defensive patterns
Strategy: type-guard
Validate before calling
import {getStszBox} from '@remotion/media-parser/containers/iso-base-media/traversal';
const stsz = getStszBox(trakBox);
if (stsz?.countType === 'fixed') { getGroupedSamplesPositionsFromMp4({trakBox, bigEndian}); } else { /* use variable-size path */ } Type guard
const hasFixedStsz = (trak: TrakBox): boolean => getStszBox(trak)?.countType === 'fixed';
Try / catch
try { getGroupedSamplesPositionsFromMp4({trakBox, bigEndian}); } catch (e) { if (e.message === 'Only supporting fixed count type in stsz box') { /* fall back to general path */ } else throw e; } Prevention
- Reserve getGroupedSamplesPositionsFromMp4 for fixed-size-sample tracks.
- Check stsz.countType before choosing the grouped path.
- Use getSamplePositionsFromTrack for compressed/variable-size tracks.
When it happens
Trigger: Calling getGroupedSamplesPositionsFromMp4 on a trak whose stsz lists per-sample sizes (countType === 'variable'), which is normal for most compressed video/audio tracks. This path is intended only for fixed-size sample tracks (e.g. some LPCM layouts).
Common situations: Routing a generic/compressed audio or video trak into the grouped-samples path by mistake. Using this function for LPCM-like handling on a track that is actually variable-sized.
Related errors
- Expected stsz box in trak box
- Expected stsz box in trak box
- Forward seeking is not allowed when the following fields are
- Expected stsc box in trak box
- Expected stco box in trak box
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/fb43e21c0a705f27.
Report an issue: GitHub.