{"record":{"id":"4c7d6189090075f6","repo":"remotion-dev/remotion","slug":"expected-track-number-segment","errorCode":null,"errorMessage":"Expected track number segment","messagePattern":"Expected track number segment","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/media-parser/src/containers/webm/traversal.ts","lineNumber":68,"sourceCode":"\n\tif (child.type !== 'TrackTimestampScale') {\n\t\tthrow new Error('Expected TrackTimestampScale');\n\t}\n\n\treturn child.value;\n};\n\nexport const getTrackByNumber = (tracks: TrackEntry[], id: number) => {\n\treturn tracks.find((track) => {\n\t\tconst trackNumber = getTrackNumber(track);\n\t\treturn trackNumber?.value === id;\n\t});\n};\n\nexport const getTrackId = (track: TrackEntry): number => {\n\tconst trackId = track.value.find((b) => b.type === 'TrackNumber');\n\tif (!trackId || trackId.type !== 'TrackNumber') {\n\t\tthrow new Error('Expected track number segment');\n\t}\n\n\treturn trackId.value.value;\n};\n\nexport const getCodecSegment = (track: TrackEntry): CodecIdSegment | null => {\n\tconst codec = track.value.find((b) => b.type === 'CodecID');\n\tif (!codec || codec.type !== 'CodecID') {\n\t\treturn null;\n\t}\n\n\treturn codec;\n};\n\nexport const getColourSegment = (track: TrackEntry): ColourSegment | null => {\n\tconst videoSegment = getVideoSegment(track);\n\tif (!videoSegment) {\n\t\treturn null;","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/remotion-dev/remotion/blob/78fe4bb3fdb5a2cd68724393d63cb223db333fa7/packages/media-parser/src/containers/webm/traversal.ts#L50-L86","documentation":"getTrackId finds the TrackNumber child of a TrackEntry and throws if it is absent or not of type TrackNumber. TrackNumber is a mandatory element of every TrackEntry per the Matroska spec, so its absence means the track entry is malformed.","triggerScenarios":"parseMedia is processing a TrackEntry that lacks a TrackNumber child - e.g. a truncated or corrupt track header, or a non-conformant muxer that wrote TrackEntry without TrackNumber. getTrackId is called when samples need to be dispatched to a track.","commonSituations":"Corrupt MKV/WebM track headers, partially written files, or binary edits that removed the TrackNumber element.","solutions":["Re-mux with ffmpeg to reconstruct TrackEntries with mandatory fields.","Validate the file with ffprobe; if tracks are missing numbers, the file is damaged.","Use a different source.","Try Mediabunny."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await parseMedia({src: 'in.mkv', fields: {tracks: true, samples: true}});\n} catch (err) {\n  if (err instanceof Error && /Expected track number segment/.test(err.message)) {\n    throw new Error('TrackEntry missing TrackNumber; re-mux the file.', {cause: err});\n  }\n  throw err;\n}","preventionTips":["Re-mux uploads so every TrackEntry has its mandatory TrackNumber.","Validate tracks with ffprobe before parsing.","Keep a fallback source/parser."],"tags":["webm","matroska","media-parser","track","malformed-file"],"backgroundTag":null,"analyzedSha":"78fe4bb3fdb5a2cd68724393d63cb223db333fa7","analyzedAt":"2026-08-12T17:18:50.444Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}