{"record":{"id":"fe94eb2531088a76","repo":"remotion-dev/remotion","slug":"could-not-find-codec-for-track-tracknumber","errorCode":null,"errorMessage":"Could not find codec for track ${trackNumber}","messagePattern":"Could not find codec for track (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/webm/get-sample-from-block.ts","lineNumber":168,"sourceCode":"\n\tconst timescale = webmState.getTimescale();\n\n\tif (clusterOffset === undefined) {\n\t\tthrow new Error('Could not find offset for byte offset ' + offset);\n\t}\n\n\t// https://github.com/hubblec4/Matroska-Chapters-Specs/blob/master/notes.md/#timestampscale\n\t// The TimestampScale Element is used to calculate the Raw Timestamp of a Block. The timestamp is obtained by adding the Block's timestamp to the Cluster's Timestamp Element, and then multiplying that result by the TimestampScale. The result will be the Block's Raw Timestamp in nanoseconds.\n\tconst timecodeInNanoSeconds =\n\t\t(timecodeRelativeToCluster + clusterOffset) *\n\t\ttimescale *\n\t\t(trackTimescale ?? 1);\n\n\t// Timecode should be in microseconds\n\tconst timecodeInMicroseconds = timecodeInNanoSeconds / 1000;\n\n\tif (!codec) {\n\t\tthrow new Error(`Could not find codec for track ${trackNumber}`);\n\t}\n\n\tconst remainingNow = ebml.value.length - iterator.counter.getOffset();\n\n\tif (codec.startsWith('V_')) {\n\t\tconst partialVideoSample: Omit<MediaParserVideoSample, 'type'> = {\n\t\t\tdata: iterator.getSlice(remainingNow),\n\t\t\tdecodingTimestamp: timecodeInMicroseconds,\n\t\t\tduration: undefined,\n\t\t\ttimestamp: timecodeInMicroseconds,\n\t\t\toffset,\n\t\t};\n\n\t\tif (keyframe === null) {\n\t\t\titerator.destroy();\n\n\t\t\treturn {\n\t\t\t\ttype: 'partial-video-sample',","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/webm/get-sample-from-block.ts#L150-L186","documentation":"Thrown at get-sample-from-block.ts:168 when `webmState.getTrackInfoByNumber(trackNumber)` returns an object with an empty/falsy `codec`. The track number encoded in the block does not map to a registered codec string, meaning the block references an unknown or not-yet-parsed track.","triggerScenarios":"A Block/SimpleBlock carries a trackNumber that was never registered during the Tracks parsing pass, or whose codec could not be resolved (e.g. a subtitle track, an unsupported codec, or a trackNumber from a different edition). The `getTrackInfoByNumber` lookup succeeds structurally but returns an empty codec.","commonSituations":"WebM files with subtitle/metadata tracks whose codec the parser ignores; AVC tracks stuck in `missingInfo` whose codec is still empty when a block arrives before profile resolution; files with multiple editions or track-number reuse.","solutions":["Confirm the file's tracks with `ffprobe` — if it contains non-A/V tracks, that is expected; the error indicates those blocks should be filtered earlier.","For AVC-in-WebM without CodecPrivate, ensure the first keyframe (with SPS) is processed before later blocks; avoid skipping it via controller seeks.","Re-mux to strip problematic tracks: `ffmpeg -i in.webm -c copy -map 0:v:0 -map 0:a:0 out.webm`.","Catch the error and skip the asset."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-list tracks; if a block-only track (e.g. subtitle) exists, expect codec misses.\nimport { parseMedia } from '@remotion/media-parser';\nasync function listTracks(src) {\n  return parseMedia({ src, fields: { tracks: true } });\n}","typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({ src, fields: { samples: true } });\n} catch (err) {\n  if (err instanceof Error && /Could not find codec for track \\d+/.test(err.message)) {\n    console.warn('Block references an unresolved/unknown track in', src);\n    return null;\n  }\n  throw err;\n}","preventionTips":["Strip non-A/V tracks before parsing: ffmpeg -map 0:v -map 0:a.","For AVC-in-WebM without CodecPrivate, ensure the first keyframe is parsed (no controller seeks past it).","Run ffprobe first to confirm all tracks have resolvable codecs."],"tags":["media-parser","webm","track-number","codec-resolution","avc"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}