{"record":{"id":"9dfe41eb968a3149","repo":"remotion-dev/remotion","slug":"could-not-find-audio-sample","errorCode":null,"errorMessage":"Could not find audio sample","messagePattern":"Could not find audio sample","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/get-audio-codec.ts","lineNumber":355,"sourceCode":"\n\t\tif (codec.primarySpecificator === 0x6b) {\n\t\t\treturn 'mp3';\n\t\t}\n\n\t\tif (codec.primarySpecificator === null) {\n\t\t\treturn 'aac';\n\t\t}\n\n\t\tthrow new Error('Unknown mp4a codec: ' + codec.primarySpecificator);\n\t}\n\n\tthrow new Error(`Unknown audio format: ${codec.format}`);\n};\n\nexport const getAudioCodecFromTrack = (track: TrakBox) => {\n\tconst audioSample = getAudioCodecFromTrak(track);\n\tif (!audioSample) {\n\t\tthrow new Error('Could not find audio sample');\n\t}\n\n\treturn getAudioCodecFromAudioCodecInfo(audioSample);\n};\n","sourceCodeStart":337,"sourceCodeEnd":360,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/get-audio-codec.ts#L337-L360","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst codec = getAudioCodecFromTrack(trak);\n\n// after\nconst info = getAudioCodecFromTrak(trak);\nif (!info) {\n  // not an audio trak; skip\n  continue;\n}\nconst codec = getAudioCodecFromAudioCodecInfo(info);","handlingStrategy":"type-guard","validationCode":"import {getAudioCodecFromTrak} from '@remotion/media-parser/get-audio-codec';\nconst info = getAudioCodecFromTrak(trak);\nif (info) { const codec = getAudioCodecFromTrack(trak); }","typeGuard":"const isAudioTrak = (trak: TrakBox): boolean => getAudioCodecFromTrak(trak) !== null;","tryCatchPattern":"try { getAudioCodecFromTrack(trak); } catch (e) { if (e.message === 'Could not find audio sample') { /* skip non-audio trak */ } else throw e; }","preventionTips":["Filter traks to audio traks before deriving codecs.","Use getAudioCodecFromTrak and handle null explicitly.","Confirm track type with ffprobe when in doubt."],"tags":["mp4","audio","codec","validation"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}