remotion-dev/remotion · error · Error

Could not find track ${trackNumber}

Error message

Could not find track ${trackNumber}

What it means

Thrown in addAvcToTrackAndActivateTrackIfNecessary (get-sample-from-block.ts:83) during lazy AVC profile resolution. After parsing an AVC profile from a block, the code looks up the producing track in the `missingInfo` list; not finding it means the track that generated the AVC data was never registered as missing — an internal state inconsistency rather than a user-facing validation failure.

Source

Thrown at packages/media-parser/src/containers/webm/get-sample-from-block.ts:83

		return;
	}

	const missingTracks = getTracksFromMatroska({
		structureState,
		webmState,
	}).missingInfo;

	if (missingTracks.length === 0) {
		return;
	}

	const parsed = parseAvc(partialVideoSample.data, avcState);
	for (const parse of parsed) {
		if (parse.type === 'avc-profile') {
			webmState.setAvcProfileForTrackNumber(trackNumber, parse);
			const track = missingTracks.find((t) => t.trackId === trackNumber);
			if (!track) {
				throw new Error('Could not find track ' + trackNumber);
			}

			const resolvedTracks = getTracksFromMatroska({
				structureState,
				webmState,
			}).resolved;
			const resolvedTrack = resolvedTracks.find(
				(t) => t.trackId === trackNumber,
			);
			if (!resolvedTrack) {
				throw new Error('Could not find track ' + trackNumber);
			}

			await registerVideoTrack({
				track: resolvedTrack,
				container: 'webm',
				logLevel,
				onVideoTrack,

View on GitHub (pinned to 78fe4bb3fd)

Solutions

  1. Treat as a bug report: capture the exact file and the call to `parseMedia()` and file it at https://remotion.dev/report.
  2. Ensure you are on the latest @remotion/media-parser version; this path depends on tightly coupled internal state.
  3. As an immediate workaround, catch the error and fall back to remuxing the file with ffmpeg so CodecPrivate is embedded (`ffmpeg -i in.webm -c copy out.mkv`).
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-validate that the AVC track carries CodecPrivate — if it does,
// this lazy-resolution path is never taken.
import { parseMedia } from '@remotion/media-parser';
async function isSafeAvcWebm(src) {
  let sawAvc = false;
  await parseMedia({
    src,
    fields: { tracks: true },
    onVideoTrack: (track) => {
      if (track.codecEnum === 'h264') sawAvc = true;
      return track;
    },
  });
  return !sawAvc; // safe only if no AVC track needs lazy resolution
}

Try / catch

try {
  await parseMedia({ src, fields: { samples: true } });
} catch (err) {
  if (err instanceof Error && err.message.startsWith('Could not find track ')) {
    // Internal invariant break during AVC profile resolution.
    // Re-mux to embed CodecPrivate, then retry.
    console.error('AVC lazy-resolution failed for', src, '— re-mux the file.');
  }
  throw err;
}

Prevention

When it happens

Trigger: Streaming/lazy parse of an AVC (H.264) WebM track whose CodecPrivate was absent (so the track sat in `missingInfo`), then the first keyframe is processed. Fires when the SPS-derived profile is set for a trackNumber that is no longer (or was never) in the `missingInfo` set returned by `getTracksFromMatroska` — e.g. concurrent/re-entrant resolution or a trackNumber mismatch between block and TrackEntry.

Common situations: AVC-in-WebM files with missing CodecPrivate where track numbering is unusual; races between sample parsing and track resolution state; bugs after refactors of `getTracksFromMatroska`. Should never occur for well-formed files and correct internal state.

Related errors


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