{"record":{"id":"2ced463df3bb3134","repo":"remotion-dev/remotion","slug":"no-tracks-yet","errorCode":null,"errorMessage":"No tracks yet","messagePattern":"No tracks yet","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/get-audio-codec.ts","lineNumber":20,"sourceCode":"import type {EsdsBox} from './containers/iso-base-media/esds/esds';\nimport type {AudioSample} from './containers/iso-base-media/stsd/samples';\nimport type {TrakBox} from './containers/iso-base-media/trak/trak';\nimport {getStsdBox} from './containers/iso-base-media/traversal';\nimport {\n\tgetHasTracks,\n\tgetTracks,\n\ttype MediaParserAudioCodec,\n} from './get-tracks';\nimport type {AnySegment} from './parse-result';\nimport type {ParserState} from './state/parser-state';\n\nexport const getAudioCodec = (\n\tparserState: ParserState,\n): MediaParserAudioCodec | null => {\n\tconst tracks = getTracks(parserState, true);\n\n\tif (tracks.length === 0) {\n\t\tthrow new Error('No tracks yet');\n\t}\n\n\tconst audioTrack = tracks.find((t) => t.type === 'audio');\n\tif (!audioTrack) {\n\t\treturn null;\n\t}\n\n\tif (audioTrack.type === 'audio') {\n\t\treturn audioTrack.codecEnum;\n\t}\n\n\treturn null;\n};\n\nexport const hasAudioCodec = (state: ParserState): boolean => {\n\treturn getHasTracks(state, true);\n};\n","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/get-audio-codec.ts#L2-L38","documentation":"Thrown by getAudioCodec(parserState) when getTracks() has returned an empty array, i.e. the parser has not yet discovered any tracks in the container. The function needs at least one track to look for an audio track; with zero tracks it throws rather than returning a misleading null (null is reserved for 'tracks exist but none are audio').","triggerScenarios":"Calling getAudioCodec during early parsing before the moov/segment-info has been processed. Calling it on a structure that has no tracks at all (e.g. a metadata-only file or wrong container type).","commonSituations":"Reading codec info synchronously right after parseMedia starts, before the 'tracks' event fires. Inspecting state in a custom reader/seeker before tracks are populated. Passing a parserState captured from a different (track-less) phase.","solutions":["Wait for the 'tracks' event (or check hasAudioCodec(state)) before calling getAudioCodec.","Guard with getTracks(parserState, true).length > 0 before invocation.","Confirm the container actually contains tracks; for non-AV containers the call is not meaningful."],"exampleFix":"// before\nconst codec = getAudioCodec(parserState);\n\n// after\nif (getTracks(parserState, true).length > 0) {\n  const codec = getAudioCodec(parserState);\n} else {\n  // wait for tracks event\n}","handlingStrategy":"validation","validationCode":"import {getTracks} from '@remotion/media-parser/get-tracks';\nif (getTracks(parserState, true).length > 0) {\n  const codec = getAudioCodec(parserState);\n}","typeGuard":"null","tryCatchPattern":"try { getAudioCodec(parserState); } catch (e) { if (e.message === 'No tracks yet') { /* wait for tracks event */ } else throw e; }","preventionTips":["Call getAudioCodec only after the 'tracks' event.","Use hasAudioCodec(state) to check readiness.","Do not read codec synchronously at parse start."],"tags":["audio","codec","tracks","lifecycle"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}