remotion-dev/remotion · error
Could not find audio sample
Error message
Could not find audio sample
What it means
Thrown by getAudioCodecFromTrack(track) when getAudioCodecFromTrak(track) returns null, i.e. the trak's stsd has no audio sample entry that the parser recognizes. The wrapper cannot proceed without an audio sample, so it throws instead of returning an undefined codec.
Source
Thrown at packages/media-parser/src/get-audio-codec.ts:355
if (codec.primarySpecificator === 0x6b) {
return 'mp3';
}
if (codec.primarySpecificator === null) {
return 'aac';
}
throw new Error('Unknown mp4a codec: ' + codec.primarySpecificator);
}
throw new Error(`Unknown audio format: ${codec.format}`);
};
export const getAudioCodecFromTrack = (track: TrakBox) => {
const audioSample = getAudioCodecFromTrak(track);
if (!audioSample) {
throw new Error('Could not find audio sample');
}
return getAudioCodecFromAudioCodecInfo(audioSample);
};
View on GitHub (pinned to 78fe4bb3fd)
Solutions
- Filter traks to audio traks before calling getAudioCodecFromTrack (e.g. via trakBoxContainsAudio or by checking the stsd sample type).
- Use getAudioCodecFromTrak directly and handle the null case explicitly.
- Confirm the file actually has an audio track with ffprobe before deriving a codec.
Example fix
// before
const codec = getAudioCodecFromTrack(trak);
// after
const info = getAudioCodecFromTrak(trak);
if (!info) {
// not an audio trak; skip
continue;
}
const codec = getAudioCodecFromAudioCodecInfo(info); Defensive patterns
Strategy: type-guard
Validate before calling
import {getAudioCodecFromTrak} from '@remotion/media-parser/get-audio-codec';
const info = getAudioCodecFromTrak(trak);
if (info) { const codec = getAudioCodecFromTrack(trak); } Type guard
const isAudioTrak = (trak: TrakBox): boolean => getAudioCodecFromTrak(trak) !== null;
Try / catch
try { getAudioCodecFromTrack(trak); } catch (e) { if (e.message === 'Could not find audio sample') { /* skip non-audio trak */ } else throw e; } Prevention
- Filter traks to audio traks before deriving codecs.
- Use getAudioCodecFromTrak and handle null explicitly.
- Confirm track type with ffprobe when in doubt.
When it happens
Trigger: Calling getAudioCodecFromTrack on a trak that contains no audio sample entry (video, hint, tmcd, chapter traks). Calling it before the stsd box has been fully populated.
Common situations: Looping over every trak in a moov and deriving codecs without filtering by media type. Processing a video-only MP4 and expecting an audio codec. Early-inspection before stsd is parsed.
Related errors
- Expected codec
- Could not find number of channels
- Could not find sample rate
- No decoder-config-descriptor
- No audio-specific-config
AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12).
Data as JSON: /api/errors/9dfe41eb968a3149.
Report an issue: GitHub.