remotion-dev/remotion · error · Error

Expected track entry segment

Error message

Expected track entry segment

What it means

Thrown while iterating the children of the Matroska `Tracks` element in get-ready-tracks.ts:44. After skipping `Crc32` children, every remaining child is required to be a `TrackEntry`; any other EBML element type violates the Matroska spec and aborts track resolution. The error indicates the parser received a structurally invalid `Tracks` segment from the EBML decoder.

Source

Thrown at packages/media-parser/src/containers/webm/get-ready-tracks.ts:44

		throw new Error('No main segment');
	}

	const tracksSegment = getTracksSegment(mainSegment);

	if (!tracksSegment) {
		throw new Error('No tracks segment');
	}

	const resolvedTracks: MediaParserTrack[] = [];
	const missingInfo: MediaParserTrack[] = [];

	for (const trackEntrySegment of tracksSegment.value) {
		if (trackEntrySegment.type === 'Crc32') {
			continue;
		}

		if (trackEntrySegment.type !== 'TrackEntry') {
			throw new Error('Expected track entry segment');
		}

		const track = getTrack({
			track: trackEntrySegment,
			timescale: webmState.getTimescale(),
		});

		if (!track) {
			continue;
		}

		if (track.codec === NO_CODEC_PRIVATE_SHOULD_BE_DERIVED_FROM_SPS) {
			const avc = webmState.getAvcProfileForTrackNumber(track.trackId);
			if (avc) {
				resolvedTracks.push({
					...track,
					codec: getCodecStringFromSpsAndPps(avc),
				});

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Re-encode or re-mux the source file with a conformant tool (ffmpeg/MKVToolNix) and retry.
  2. Verify the file integrity: compare checksums, re-download, or run `ffprobe` to confirm it parses elsewhere.
  3. If the file is valid, report it to Remotion with the example file at https://remotion.dev/report so the EBML traversal can be extended.
  4. Wrap the `parseMedia()` call in try/catch and degrade gracefully (skip the asset, log the error) since this is unrecoverable for that input.

Example fix

// before
const { tracks } = await parseMedia({ src, fields: { tracks: true } });

// after
try {
  const { tracks } = await parseMedia({ src, fields: { tracks: true } });
} catch (err) {
  console.error('Unparseable WebM container:', err);
  // fall back to a known-good asset or skip
}
Defensive patterns

Strategy: try-catch

Validate before calling

// No pre-parse validation possible — the defect is inside the EBML tree.
// Best-effort: reject obviously non-WebM sources before parsing.
import { parseMedia } from '@remotion/media-parser';
async function safeParse(src) {
  if (src instanceof Blob && !/webm|matroska|mkv/i.test(src.type)) {
    throw new Error('Source does not look like a WebM/Matroska container');
  }
  return parseMedia({ src, fields: { tracks: true } });
}

Try / catch

try {
  const result = await parseMedia({ src, fields: { tracks: true } });
} catch (err) {
  if (err instanceof Error && err.message === 'Expected track entry segment') {
    // Unrecoverable: the container structure is malformed.
    console.warn('Malformed WebM container, skipping asset:', src);
    return null;
  }
  throw err;
}

Prevention

When it happens

Trigger: Called transitively from `parseMedia()` (or `parseMediaInWorker`) on a WebM/MKV stream whose `Tracks` element contains an element other than `TrackEntry` or `Crc32`. Also reachable if the EBML parser mis-segments the byte stream due to truncation or a malformed Vint size field, producing a spurious child type.

Common situations: Corrupt or partially downloaded .webm/.mkv files; files produced by non-conformant muxers that insert undocumented elements under `Tracks`; byte-level truncation where a Cluster bleeds into the Tracks box. Rare in practice — most muxers emit only TrackEntry children.

Related errors


AI-assisted analysis of remotion-dev/remotion@78fe4bb3fd (2026-08-12). Data as JSON: /api/errors/205748881d40636a. Report an issue: GitHub.